rbs 3.10.0 → 4.0.0.dev.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 (202) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +3 -3
  3. data/.github/workflows/ruby.yml +24 -35
  4. data/.github/workflows/typecheck.yml +3 -1
  5. data/.github/workflows/windows.yml +2 -2
  6. data/.gitignore +0 -4
  7. data/CHANGELOG.md +0 -88
  8. data/README.md +1 -38
  9. data/Rakefile +20 -142
  10. data/Steepfile +1 -0
  11. data/config.yml +43 -1
  12. data/core/array.rbs +46 -100
  13. data/core/complex.rbs +21 -32
  14. data/core/dir.rbs +2 -2
  15. data/core/encoding.rbs +9 -6
  16. data/core/enumerable.rbs +3 -90
  17. data/core/enumerator.rbs +1 -18
  18. data/core/errno.rbs +0 -8
  19. data/core/errors.rbs +1 -28
  20. data/core/exception.rbs +2 -2
  21. data/core/fiber.rbs +4 -5
  22. data/core/file.rbs +12 -27
  23. data/core/file_test.rbs +1 -1
  24. data/core/float.rbs +22 -209
  25. data/core/gc.rbs +281 -417
  26. data/core/hash.rbs +727 -1024
  27. data/core/integer.rbs +38 -78
  28. data/core/io/buffer.rbs +7 -18
  29. data/core/io/wait.rbs +33 -11
  30. data/core/io.rbs +12 -14
  31. data/core/kernel.rbs +51 -57
  32. data/core/marshal.rbs +1 -1
  33. data/core/match_data.rbs +1 -1
  34. data/core/math.rbs +3 -42
  35. data/core/method.rbs +6 -14
  36. data/core/module.rbs +17 -88
  37. data/core/nil_class.rbs +3 -3
  38. data/core/numeric.rbs +16 -16
  39. data/core/object.rbs +3 -3
  40. data/core/object_space.rbs +15 -21
  41. data/core/proc.rbs +8 -15
  42. data/core/process.rbs +2 -2
  43. data/core/ractor.rbs +437 -278
  44. data/core/range.rbs +8 -7
  45. data/core/rational.rbs +24 -37
  46. data/core/rbs/unnamed/argf.rbs +2 -2
  47. data/core/rbs/unnamed/env_class.rbs +1 -1
  48. data/core/rbs/unnamed/random.rbs +2 -4
  49. data/core/regexp.rbs +20 -25
  50. data/core/ruby_vm.rbs +4 -6
  51. data/core/rubygems/errors.rbs +70 -3
  52. data/core/rubygems/rubygems.rbs +79 -11
  53. data/core/rubygems/version.rbs +3 -2
  54. data/core/set.rbs +359 -488
  55. data/core/string.rbs +1228 -3153
  56. data/core/struct.rbs +1 -1
  57. data/core/symbol.rbs +4 -4
  58. data/core/thread.rbs +29 -92
  59. data/core/time.rbs +9 -35
  60. data/core/trace_point.rbs +4 -7
  61. data/core/unbound_method.rbs +6 -14
  62. data/docs/collection.md +2 -2
  63. data/docs/gem.md +1 -0
  64. data/docs/sigs.md +3 -3
  65. data/ext/rbs_extension/ast_translation.c +1077 -944
  66. data/ext/rbs_extension/ast_translation.h +0 -7
  67. data/ext/rbs_extension/class_constants.c +83 -71
  68. data/ext/rbs_extension/class_constants.h +7 -4
  69. data/ext/rbs_extension/extconf.rb +2 -24
  70. data/ext/rbs_extension/legacy_location.c +172 -173
  71. data/ext/rbs_extension/legacy_location.h +3 -8
  72. data/ext/rbs_extension/main.c +289 -239
  73. data/ext/rbs_extension/rbs_extension.h +0 -3
  74. data/ext/rbs_extension/rbs_string_bridging.h +0 -4
  75. data/include/rbs/ast.h +98 -37
  76. data/include/rbs/defines.h +12 -38
  77. data/include/rbs/lexer.h +114 -126
  78. data/include/rbs/location.h +14 -14
  79. data/include/rbs/parser.h +37 -21
  80. data/include/rbs/string.h +5 -3
  81. data/include/rbs/util/rbs_allocator.h +19 -40
  82. data/include/rbs/util/rbs_assert.h +1 -12
  83. data/include/rbs/util/rbs_constant_pool.h +3 -3
  84. data/include/rbs/util/rbs_encoding.h +1 -3
  85. data/include/rbs/util/rbs_unescape.h +1 -2
  86. data/lib/rbs/ast/ruby/annotations.rb +119 -0
  87. data/lib/rbs/ast/ruby/comment_block.rb +221 -0
  88. data/lib/rbs/ast/ruby/declarations.rb +86 -0
  89. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +24 -0
  90. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  91. data/lib/rbs/ast/ruby/members.rb +213 -0
  92. data/lib/rbs/buffer.rb +104 -24
  93. data/lib/rbs/cli/validate.rb +40 -35
  94. data/lib/rbs/cli.rb +5 -6
  95. data/lib/rbs/collection/config/lockfile_generator.rb +0 -1
  96. data/lib/rbs/collection.rb +0 -1
  97. data/lib/rbs/definition.rb +6 -1
  98. data/lib/rbs/definition_builder/ancestor_builder.rb +65 -62
  99. data/lib/rbs/definition_builder/method_builder.rb +45 -30
  100. data/lib/rbs/definition_builder.rb +44 -9
  101. data/lib/rbs/environment/class_entry.rb +69 -0
  102. data/lib/rbs/environment/module_entry.rb +66 -0
  103. data/lib/rbs/environment.rb +244 -218
  104. data/lib/rbs/environment_loader.rb +3 -3
  105. data/lib/rbs/errors.rb +5 -4
  106. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  107. data/lib/rbs/inline_parser.rb +206 -0
  108. data/lib/rbs/location_aux.rb +35 -3
  109. data/lib/rbs/parser_aux.rb +11 -6
  110. data/lib/rbs/prototype/runtime.rb +2 -2
  111. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  112. data/lib/rbs/resolver/type_name_resolver.rb +38 -124
  113. data/lib/rbs/source.rb +99 -0
  114. data/lib/rbs/subtractor.rb +4 -3
  115. data/lib/rbs/test/type_check.rb +0 -14
  116. data/lib/rbs/types.rb +1 -3
  117. data/lib/rbs/version.rb +1 -1
  118. data/lib/rbs.rb +13 -1
  119. data/lib/rdoc/discover.rb +1 -1
  120. data/lib/rdoc_plugin/parser.rb +1 -1
  121. data/rbs.gemspec +1 -0
  122. data/sig/ancestor_builder.rbs +1 -1
  123. data/sig/ast/ruby/annotations.rbs +110 -0
  124. data/sig/ast/ruby/comment_block.rbs +119 -0
  125. data/sig/ast/ruby/declarations.rbs +60 -0
  126. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  127. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  128. data/sig/ast/ruby/members.rbs +72 -0
  129. data/sig/buffer.rbs +63 -5
  130. data/sig/definition.rbs +1 -0
  131. data/sig/definition_builder.rbs +1 -1
  132. data/sig/environment/class_entry.rbs +50 -0
  133. data/sig/environment/module_entry.rbs +50 -0
  134. data/sig/environment.rbs +28 -133
  135. data/sig/errors.rbs +13 -6
  136. data/sig/inline_parser/comment_association.rbs +71 -0
  137. data/sig/inline_parser.rbs +87 -0
  138. data/sig/location.rbs +32 -7
  139. data/sig/manifest.yaml +1 -0
  140. data/sig/method_builder.rbs +7 -4
  141. data/sig/parser.rbs +16 -20
  142. data/sig/resolver/type_name_resolver.rbs +7 -38
  143. data/sig/source.rbs +48 -0
  144. data/sig/types.rbs +1 -4
  145. data/src/ast.c +290 -201
  146. data/src/lexer.c +2813 -2902
  147. data/src/lexer.re +4 -0
  148. data/src/lexstate.c +155 -169
  149. data/src/location.c +40 -40
  150. data/src/parser.c +2665 -2433
  151. data/src/string.c +48 -0
  152. data/src/util/rbs_allocator.c +77 -80
  153. data/src/util/rbs_assert.c +10 -10
  154. data/src/util/rbs_buffer.c +2 -2
  155. data/src/util/rbs_constant_pool.c +15 -13
  156. data/src/util/rbs_encoding.c +4062 -20097
  157. data/src/util/rbs_unescape.c +48 -85
  158. data/stdlib/bigdecimal/0/big_decimal.rbs +82 -100
  159. data/stdlib/bigdecimal-math/0/big_math.rbs +8 -169
  160. data/stdlib/cgi/0/core.rbs +396 -2
  161. data/stdlib/cgi/0/manifest.yaml +0 -1
  162. data/stdlib/coverage/0/coverage.rbs +1 -3
  163. data/stdlib/date/0/date.rbs +59 -67
  164. data/stdlib/date/0/date_time.rbs +1 -1
  165. data/stdlib/delegate/0/delegator.rbs +7 -10
  166. data/stdlib/erb/0/erb.rbs +347 -737
  167. data/stdlib/fileutils/0/fileutils.rbs +13 -18
  168. data/stdlib/forwardable/0/forwardable.rbs +0 -3
  169. data/stdlib/json/0/json.rbs +48 -68
  170. data/stdlib/net-http/0/net-http.rbs +0 -3
  171. data/stdlib/objspace/0/objspace.rbs +4 -9
  172. data/stdlib/open-uri/0/open-uri.rbs +0 -40
  173. data/stdlib/openssl/0/openssl.rbs +228 -331
  174. data/stdlib/optparse/0/optparse.rbs +3 -3
  175. data/{core → stdlib/pathname/0}/pathname.rbs +355 -255
  176. data/stdlib/psych/0/psych.rbs +3 -3
  177. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  178. data/stdlib/resolv/0/resolv.rbs +68 -25
  179. data/stdlib/ripper/0/ripper.rbs +2 -5
  180. data/stdlib/singleton/0/singleton.rbs +0 -3
  181. data/stdlib/socket/0/socket.rbs +1 -13
  182. data/stdlib/socket/0/tcp_socket.rbs +2 -10
  183. data/stdlib/stringio/0/stringio.rbs +85 -1176
  184. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  185. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  186. data/stdlib/time/0/time.rbs +1 -1
  187. data/stdlib/timeout/0/timeout.rbs +7 -63
  188. data/stdlib/tsort/0/cyclic.rbs +0 -3
  189. data/stdlib/uri/0/common.rbs +2 -11
  190. data/stdlib/uri/0/file.rbs +1 -1
  191. data/stdlib/uri/0/generic.rbs +16 -17
  192. data/stdlib/uri/0/rfc2396_parser.rbs +7 -6
  193. data/stdlib/zlib/0/zstream.rbs +0 -1
  194. metadata +40 -12
  195. data/.clang-format +0 -74
  196. data/.clangd +0 -2
  197. data/.github/workflows/c-check.yml +0 -54
  198. data/core/ruby.rbs +0 -53
  199. data/docs/aliases.md +0 -79
  200. data/docs/encoding.md +0 -56
  201. data/ext/rbs_extension/compat.h +0 -10
  202. data/stdlib/cgi-escape/0/escape.rbs +0 -153
@@ -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 OpenSSL::SSL::SSLContext is used to set up an SSL session.
370
+ # An 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 OpenSSL::SSL::SSLServer with a TCP server socket and the
383
- # context. Use the SSLServer like an ordinary TCP server.
382
+ # Then create an SSLServer with a TCP server socket and the context. Use the
383
+ # SSLServer like an ordinary TCP server.
384
384
  #
385
385
  # require 'socket'
386
386
  #
@@ -401,13 +401,12 @@
401
401
  #
402
402
  # ### SSL client
403
403
  #
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.
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.
408
407
  #
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.
408
+ # Note that SSLSocket#close doesn't close the underlying socket by default. Set
409
+ # SSLSocket#sync_close to true if you want.
411
410
  #
412
411
  # require 'socket'
413
412
  #
@@ -456,7 +455,7 @@ module OpenSSL
456
455
  # OpenSSL::Digest("MD5")
457
456
  # # => OpenSSL::Digest::MD5
458
457
  #
459
- # OpenSSL::Digest("Foo")
458
+ # Digest("Foo")
460
459
  # # => NameError: wrong constant name Foo
461
460
  #
462
461
  def self.Digest: (String name) -> singleton(Digest)
@@ -465,13 +464,12 @@ module OpenSSL
465
464
  # rdoc-file=ext/openssl/ossl.c
466
465
  # - OpenSSL.debug -> true | false
467
466
  # -->
468
- # Returns whether Ruby/OpenSSL's debug mode is currently enabled.
469
467
  #
470
468
  def self.debug: () -> bool
471
469
 
472
470
  # <!--
473
471
  # rdoc-file=ext/openssl/ossl.c
474
- # - OpenSSL.debug = boolean
472
+ # - OpenSSL.debug = boolean -> boolean
475
473
  # -->
476
474
  # Turns on or off debug mode. With debug mode, all errors added to the OpenSSL
477
475
  # error queue will be printed to stderr.
@@ -482,14 +480,10 @@ module OpenSSL
482
480
  # rdoc-file=ext/openssl/ossl.c
483
481
  # - OpenSSL.errors -> [String...]
484
482
  # -->
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.
483
+ # See any remaining errors held in queue.
487
484
  #
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.
485
+ # Any errors you see here are probably due to a bug in Ruby's OpenSSL
486
+ # implementation.
493
487
  #
494
488
  def self.errors: () -> Array[String]
495
489
 
@@ -497,13 +491,12 @@ module OpenSSL
497
491
  # rdoc-file=ext/openssl/ossl.c
498
492
  # - OpenSSL.fips_mode -> true | false
499
493
  # -->
500
- # Returns whether the FIPS mode is currently enabled.
501
494
  #
502
495
  def self.fips_mode: () -> bool
503
496
 
504
497
  # <!--
505
498
  # rdoc-file=ext/openssl/ossl.c
506
- # - OpenSSL.fips_mode = boolean
499
+ # - OpenSSL.fips_mode = boolean -> boolean
507
500
  # -->
508
501
  # Turns FIPS mode on or off. Turning on FIPS mode will obviously only have an
509
502
  # effect for FIPS-capable installations of the OpenSSL library. Trying to do so
@@ -517,74 +510,57 @@ module OpenSSL
517
510
 
518
511
  # <!--
519
512
  # rdoc-file=ext/openssl/ossl.c
520
- # - OpenSSL.fixed_length_secure_compare(string, string) -> true or false
513
+ # - OpenSSL.fixed_length_secure_compare(string, string) -> boolean
521
514
  # -->
522
515
  # Constant time memory comparison for fixed length strings, such as results of
523
516
  # HMAC calculations.
524
517
  #
525
518
  # Returns `true` if the strings are identical, `false` if they are of the same
526
- # length but not identical. If the length is different, ArgumentError is raised.
519
+ # length but not identical. If the length is different, `ArgumentError` is
520
+ # raised.
527
521
  #
528
522
  def self.fixed_length_secure_compare: (String, String) -> bool
529
523
 
530
524
  # <!--
531
525
  # rdoc-file=ext/openssl/lib/openssl.rb
532
- # - OpenSSL.secure_compare(string, string) -> true or false
526
+ # - OpenSSL.secure_compare(string, string) -> boolean
533
527
  # -->
534
528
  # Constant time memory comparison. Inputs are hashed using SHA-256 to mask the
535
529
  # length of the secret. Returns `true` if the strings are identical, `false`
536
530
  # otherwise.
537
531
  #
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
- #
542
532
  def self.secure_compare: (String a, String b) -> bool
543
533
 
544
534
  # <!-- rdoc-file=ext/openssl/ossl.c -->
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.
535
+ # Boolean indicating whether OpenSSL is FIPS-capable or not
550
536
  #
551
537
  OPENSSL_FIPS: bool
552
538
 
553
- # <!-- rdoc-file=ext/openssl/ossl.c -->
554
- # OpenSSL library version string currently used at runtime.
555
- #
556
539
  OPENSSL_LIBRARY_VERSION: String
557
540
 
558
541
  # <!-- rdoc-file=ext/openssl/ossl.c -->
559
- # OpenSSL library version string used to compile the Ruby/OpenSSL extension.
560
- # This may differ from the version used at runtime.
542
+ # Version of OpenSSL the ruby OpenSSL extension was built with
561
543
  #
562
544
  OPENSSL_VERSION: String
563
545
 
564
546
  # <!-- rdoc-file=ext/openssl/ossl.c -->
565
- # OpenSSL library version number used to compile the Ruby/OpenSSL extension.
566
- # This may differ from the version used at runtime.
547
+ # Version number of OpenSSL the ruby OpenSSL extension was built with (base 16).
548
+ # The formats are below.
567
549
  #
568
- # The version number is encoded into a single integer value. The number follows
569
- # the format:
550
+ # OpenSSL 3
551
+ # : `0xMNN00PP0 (major minor 00 patch 0)`
570
552
  #
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)
553
+ # OpenSSL before 3
554
+ # : `0xMNNFFPPS (major minor fix patch status)`
576
555
  #
577
556
  # LibreSSL
578
- # : `0x20000000` (a fixed value)
557
+ # : `0x20000000 (fixed value)`
579
558
  #
580
559
  #
581
560
  # See also the man page OPENSSL_VERSION_NUMBER(3).
582
561
  #
583
562
  OPENSSL_VERSION_NUMBER: Integer
584
563
 
585
- # <!-- rdoc-file=ext/openssl/lib/openssl/version.rb -->
586
- # The version string of Ruby/OpenSSL.
587
- #
588
564
  VERSION: String
589
565
 
590
566
  # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
@@ -955,7 +931,7 @@ module OpenSSL
955
931
  # puts int2.value # => 1
956
932
  #
957
933
  class ASN1Data
958
- # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
934
+ # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
959
935
  # Never `nil`. A boolean value indicating whether the encoding uses indefinite
960
936
  # length (in the case of parsing) or whether an indefinite length form shall be
961
937
  # used (in the encoding case). In DER, every value uses definite length form.
@@ -972,7 +948,7 @@ module OpenSSL
972
948
  #
973
949
  def indefinite_length: () -> bool
974
950
 
975
- # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
951
+ # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
976
952
  # Never `nil`. A boolean value indicating whether the encoding uses indefinite
977
953
  # length (in the case of parsing) or whether an indefinite length form shall be
978
954
  # used (in the encoding case). In DER, every value uses definite length form.
@@ -989,7 +965,7 @@ module OpenSSL
989
965
  #
990
966
  def indefinite_length=: [U] (boolish) -> U
991
967
 
992
- # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
968
+ # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
993
969
  # Never `nil`. A boolean value indicating whether the encoding uses indefinite
994
970
  # length (in the case of parsing) or whether an indefinite length form shall be
995
971
  # used (in the encoding case). In DER, every value uses definite length form.
@@ -1006,7 +982,7 @@ module OpenSSL
1006
982
  #
1007
983
  alias infinite_length indefinite_length
1008
984
 
1009
- # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
985
+ # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1010
986
  # Never `nil`. A boolean value indicating whether the encoding uses indefinite
1011
987
  # length (in the case of parsing) or whether an indefinite length form shall be
1012
988
  # used (in the encoding case). In DER, every value uses definite length form.
@@ -1023,24 +999,24 @@ module OpenSSL
1023
999
  #
1024
1000
  alias infinite_length= indefinite_length=
1025
1001
 
1026
- # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1002
+ # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1027
1003
  # An Integer representing the tag number of this ASN1Data. Never `nil`.
1028
1004
  #
1029
1005
  def tag: () -> bn
1030
1006
 
1031
- # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1007
+ # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1032
1008
  # An Integer representing the tag number of this ASN1Data. Never `nil`.
1033
1009
  #
1034
1010
  def tag=: (::Integer) -> ::Integer
1035
1011
  | (BN) -> BN
1036
1012
 
1037
- # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1013
+ # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1038
1014
  # A Symbol representing the tag class of this ASN1Data. Never `nil`. See
1039
1015
  # ASN1Data for possible values.
1040
1016
  #
1041
1017
  def tag_class: () -> tag_class
1042
1018
 
1043
- # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1019
+ # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1044
1020
  # A Symbol representing the tag class of this ASN1Data. Never `nil`. See
1045
1021
  # ASN1Data for possible values.
1046
1022
  #
@@ -1057,13 +1033,13 @@ module OpenSSL
1057
1033
  #
1058
1034
  def to_der: () -> String
1059
1035
 
1060
- # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1036
+ # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1061
1037
  # Carries the value of a ASN.1 type. Please confer Constructive and Primitive
1062
1038
  # for the mappings between ASN.1 data types and Ruby classes.
1063
1039
  #
1064
1040
  def value: () -> untyped
1065
1041
 
1066
- # <!-- rdoc-file=ext/openssl/ossl_asn1.c -->
1042
+ # <!-- rdoc-file=ext/openssl/lib/openssl/asn1.rb -->
1067
1043
  # Carries the value of a ASN.1 type. Please confer Constructive and Primitive
1068
1044
  # for the mappings between ASN.1 data types and Ruby classes.
1069
1045
  #
@@ -1072,7 +1048,7 @@ module OpenSSL
1072
1048
  private
1073
1049
 
1074
1050
  # <!--
1075
- # rdoc-file=ext/openssl/ossl_asn1.c
1051
+ # rdoc-file=ext/openssl/lib/openssl/asn1.rb
1076
1052
  # - OpenSSL::ASN1::ASN1Data.new(value, tag, tag_class) => ASN1Data
1077
1053
  # -->
1078
1054
  # *value*: Please have a look at Constructive and Primitive to see how Ruby
@@ -1144,7 +1120,7 @@ module OpenSSL
1144
1120
  include Enumerable[ASN1Data]
1145
1121
 
1146
1122
  # <!--
1147
- # rdoc-file=ext/openssl/ossl_asn1.c
1123
+ # rdoc-file=ext/openssl/lib/openssl/asn1.rb
1148
1124
  # - asn1_ary.each { |asn1| block } => asn1_ary
1149
1125
  # -->
1150
1126
  # Calls the given block once for each element in self, passing that element as
@@ -2452,28 +2428,24 @@ module OpenSSL
2452
2428
  # prevents malicious modifications of the ciphertext that could otherwise be
2453
2429
  # exploited to modify ciphertexts in ways beneficial to potential attackers.
2454
2430
  #
2455
- # Associated data, also called additional authenticated data (AAD), is
2456
- # optionally used where there is additional information, such as headers or some
2457
- # metadata, that must be also authenticated but not necessarily need to be
2458
- # encrypted.
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.
2459
2436
  #
2460
2437
  # An example using the GCM (Galois/Counter Mode). You have 16 bytes *key*, 12
2461
2438
  # bytes (96 bits) *nonce* and the associated data *auth_data*. Be sure not to
2462
2439
  # reuse the *key* and *nonce* pair. Reusing an nonce ruins the security
2463
2440
  # guarantees of GCM mode.
2464
2441
  #
2465
- # key = OpenSSL::Random.random_bytes(16)
2466
- # nonce = OpenSSL::Random.random_bytes(12)
2467
- # auth_data = "authenticated but unencrypted data"
2468
- # data = "encrypted data"
2469
- #
2470
2442
  # cipher = OpenSSL::Cipher.new('aes-128-gcm').encrypt
2471
2443
  # cipher.key = key
2472
2444
  # cipher.iv = nonce
2473
2445
  # cipher.auth_data = auth_data
2474
2446
  #
2475
2447
  # encrypted = cipher.update(data) + cipher.final
2476
- # tag = cipher.auth_tag(16)
2448
+ # tag = cipher.auth_tag # produces 16 bytes tag by default
2477
2449
  #
2478
2450
  # Now you are the receiver. You know the *key* and have received *nonce*,
2479
2451
  # *auth_data*, *encrypted* and *tag* through an untrusted network. Note that GCM
@@ -2486,17 +2458,13 @@ module OpenSSL
2486
2458
  # decipher = OpenSSL::Cipher.new('aes-128-gcm').decrypt
2487
2459
  # decipher.key = key
2488
2460
  # decipher.iv = nonce
2489
- # decipher.auth_tag = tag # could be called at any time before #final
2461
+ # decipher.auth_tag = tag
2490
2462
  # decipher.auth_data = auth_data
2491
2463
  #
2492
2464
  # decrypted = decipher.update(encrypted) + decipher.final
2493
2465
  #
2494
2466
  # puts data == decrypted #=> true
2495
2467
  #
2496
- # Note that other AEAD ciphers may require additional steps, such as setting the
2497
- # expected tag length (#auth_tag_len=) or the total data length (#ccm_data_len=)
2498
- # in advance. Make sure to read the relevant man page for details.
2499
- #
2500
2468
  class Cipher
2501
2469
  # <!--
2502
2470
  # rdoc-file=ext/openssl/ossl_cipher.c
@@ -2508,22 +2476,21 @@ module OpenSSL
2508
2476
 
2509
2477
  # <!--
2510
2478
  # rdoc-file=ext/openssl/ossl_cipher.c
2511
- # - cipher.auth_data = string
2512
- # -->
2513
- # Sets additional authenticated data (AAD), also called associated data, for
2514
- # this Cipher. This method is available for AEAD ciphers.
2515
- #
2516
- # The contents of this field should be non-sensitive data which will be added to
2517
- # the ciphertext to generate the authentication tag which validates the contents
2518
- # of the ciphertext.
2519
- #
2520
- # This method must be called after #key= and #iv= have been set, but before
2521
- # starting actual encryption or decryption with #update. In some cipher modes,
2522
- # #auth_tag_len= and #ccm_data_len= may also need to be called before this
2523
- # method.
2524
- #
2525
- # See also the "AEAD Interface" section of the man page EVP_EncryptInit(3). This
2526
- # method internally calls EVP_CipherUpdate() with the output buffer set to NULL.
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.
2527
2494
  #
2528
2495
  def auth_data=: (String) -> String
2529
2496
 
@@ -2531,54 +2498,42 @@ module OpenSSL
2531
2498
  # rdoc-file=ext/openssl/ossl_cipher.c
2532
2499
  # - cipher.auth_tag(tag_len = 16) -> String
2533
2500
  # -->
2534
- # Gets the generated authentication tag. This method is available for AEAD
2535
- # ciphers, and should be called after encryption has been finalized by calling
2536
- # #final.
2537
- #
2538
- # The returned tag will be *tag_len* bytes long. Some cipher modes require the
2539
- # desired length in advance using a separate call to #auth_tag_len=, before
2540
- # starting encryption.
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.
2541
2508
  #
2542
- # See also the "AEAD Interface" section of the man page EVP_EncryptInit(3). This
2543
- # method internally calls EVP_CIPHER_CTX_ctrl() with EVP_CTRL_AEAD_GET_TAG.
2509
+ # The tag may only be retrieved after calling Cipher#final.
2544
2510
  #
2545
2511
  def auth_tag: (?Integer tag_len) -> String
2546
2512
 
2547
2513
  # <!--
2548
2514
  # rdoc-file=ext/openssl/ossl_cipher.c
2549
- # - cipher.auth_tag = string
2515
+ # - cipher.auth_tag = string -> string
2550
2516
  # -->
2551
- # Sets the authentication tag to verify the integrity of the ciphertext.
2552
- #
2553
- # The authentication tag must be set before #final is called. The tag is
2554
- # verified during the #final call.
2555
- #
2556
- # Note that, for CCM mode and OCB mode, the expected length of the tag must be
2557
- # set before starting decryption by a separate call to #auth_tag_len=. The
2558
- # content of the tag can be provided at any time before #final is called.
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.
2559
2522
  #
2560
- # **NOTE**: The caller must ensure that the String passed to this method has the
2561
- # desired length. Some cipher modes support variable tag lengths, and this
2562
- # method may accept a truncated tag without raising an exception.
2563
- #
2564
- # See also the "AEAD Interface" section of the man page EVP_EncryptInit(3). This
2565
- # method internally calls EVP_CIPHER_CTX_ctrl() with EVP_CTRL_AEAD_SET_TAG.
2523
+ # For OCB mode, the tag length must be supplied with #auth_tag_len= beforehand.
2566
2524
  #
2567
2525
  def auth_tag=: (String) -> String
2568
2526
 
2569
2527
  # <!--
2570
2528
  # rdoc-file=ext/openssl/ossl_cipher.c
2571
- # - cipher.auth_tag_len = integer
2529
+ # - cipher.auth_tag_len = Integer -> Integer
2572
2530
  # -->
2573
- # Sets the length of the expected authentication tag for this Cipher. This
2574
- # method is available for some of AEAD ciphers that require the length to be set
2575
- # before starting encryption or decryption, such as CCM mode or OCB mode.
2576
- #
2577
- # For CCM mode and OCB mode, the tag length must be set before #iv= is set.
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.
2578
2534
  #
2579
- # See also the "AEAD Interface" section of the man page EVP_EncryptInit(3). This
2580
- # method internally calls EVP_CIPHER_CTX_ctrl() with EVP_CTRL_AEAD_SET_TAG and a
2581
- # NULL buffer.
2535
+ # In OCB mode, the length must be supplied both when encrypting and when
2536
+ # decrypting, and must be before specifying an IV.
2582
2537
  #
2583
2538
  def auth_tag_len=: (Integer) -> Integer
2584
2539
 
@@ -2586,7 +2541,7 @@ module OpenSSL
2586
2541
  # rdoc-file=ext/openssl/ossl_cipher.c
2587
2542
  # - cipher.authenticated? -> true | false
2588
2543
  # -->
2589
- # Indicates whether this Cipher instance uses an AEAD mode.
2544
+ # Indicated whether this Cipher instance uses an Authenticated Encryption mode.
2590
2545
  #
2591
2546
  def authenticated?: () -> bool
2592
2547
 
@@ -2604,9 +2559,11 @@ module OpenSSL
2604
2559
  # -->
2605
2560
  # Initializes the Cipher for decryption.
2606
2561
  #
2607
- # Make sure to call either #encrypt or #decrypt before using the Cipher for any
2608
- # operation or setting any parameters.
2562
+ # Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the
2563
+ # following methods:
2609
2564
  #
2565
+ # #key=, #iv=, #random_key, #random_iv, #pkcs5_keyivgen
2566
+ # :
2610
2567
  # Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 0).
2611
2568
  #
2612
2569
  def decrypt: () -> self
@@ -2617,9 +2574,11 @@ module OpenSSL
2617
2574
  # -->
2618
2575
  # Initializes the Cipher for encryption.
2619
2576
  #
2620
- # Make sure to call either #encrypt or #decrypt before using the Cipher for any
2621
- # operation or setting any parameters.
2577
+ # Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the
2578
+ # following methods:
2622
2579
  #
2580
+ # #key=, #iv=, #random_key, #random_iv, #pkcs5_keyivgen
2581
+ # :
2623
2582
  # Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 1).
2624
2583
  #
2625
2584
  def encrypt: () -> self
@@ -2629,37 +2588,28 @@ module OpenSSL
2629
2588
  # - cipher.final -> string
2630
2589
  # -->
2631
2590
  # Returns the remaining data held in the cipher object. Further calls to
2632
- # Cipher#update or Cipher#final are invalid. This call should always be made as
2633
- # the last call of an encryption or decryption operation, after having fed the
2634
- # entire plaintext or ciphertext to the Cipher instance.
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.
2635
2594
  #
2636
- # When encrypting using an AEAD cipher, the authentication tag can be retrieved
2637
- # by #auth_tag after #final has been called.
2638
- #
2639
- # When decrypting using an AEAD cipher, this method will verify the integrity of
2640
- # the ciphertext and the associated data with the authentication tag, which must
2641
- # be set by #auth_tag= prior to calling this method. If the verification fails,
2642
- # CipherError will be raised.
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.
2643
2599
  #
2644
2600
  def final: () -> String
2645
2601
 
2646
2602
  # <!--
2647
2603
  # rdoc-file=ext/openssl/ossl_cipher.c
2648
- # - cipher.iv = string
2604
+ # - cipher.iv = string -> string
2649
2605
  # -->
2650
2606
  # Sets the cipher IV. Please note that since you should never be using ECB mode,
2651
2607
  # an IV is always explicitly required and should be set prior to encryption. The
2652
- # IV itself can be safely transmitted in public.
2653
- #
2654
- # This method expects the String to have the length equal to #iv_len. To use a
2655
- # different IV length with an AEAD cipher, #iv_len= must be set prior to calling
2656
- # this method.
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.
2657
2611
  #
2658
- # **NOTE**: In OpenSSL API conventions, the IV value may correspond to the
2659
- # "nonce" instead in some cipher modes. Refer to the OpenSSL man pages for
2660
- # details.
2661
- #
2662
- # See also the man page EVP_CipherInit_ex(3).
2612
+ # Only call this method after calling Cipher#encrypt or Cipher#decrypt.
2663
2613
  #
2664
2614
  def iv=: (String iv) -> String
2665
2615
 
@@ -2673,20 +2623,17 @@ module OpenSSL
2673
2623
 
2674
2624
  # <!--
2675
2625
  # rdoc-file=ext/openssl/ossl_cipher.c
2676
- # - cipher.iv_len = integer
2626
+ # - cipher.iv_len = integer -> integer
2677
2627
  # -->
2678
- # Sets the IV/nonce length for this Cipher. This method is available for AEAD
2679
- # ciphers that support variable IV lengths. This method can be called if a
2680
- # different IV length than OpenSSL's default is desired, prior to calling #iv=.
2681
- #
2682
- # See also the "AEAD Interface" section of the man page EVP_EncryptInit(3). This
2683
- # method internally calls EVP_CIPHER_CTX_ctrl() with EVP_CTRL_AEAD_SET_IVLEN.
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.
2684
2631
  #
2685
2632
  def iv_len=: (Integer) -> Integer
2686
2633
 
2687
2634
  # <!--
2688
2635
  # rdoc-file=ext/openssl/ossl_cipher.c
2689
- # - cipher.key = string
2636
+ # - cipher.key = string -> string
2690
2637
  # -->
2691
2638
  # Sets the cipher key. To generate a key, you should either use a secure random
2692
2639
  # byte string or, if the key is to be derived from a password, you should rely
@@ -2695,8 +2642,6 @@ module OpenSSL
2695
2642
  #
2696
2643
  # Only call this method after calling Cipher#encrypt or Cipher#decrypt.
2697
2644
  #
2698
- # See also the man page EVP_CipherInit_ex(3).
2699
- #
2700
2645
  def key=: (String key) -> String
2701
2646
 
2702
2647
  # <!--
@@ -2709,7 +2654,7 @@ module OpenSSL
2709
2654
 
2710
2655
  # <!--
2711
2656
  # rdoc-file=ext/openssl/ossl_cipher.c
2712
- # - cipher.key_len = integer
2657
+ # - cipher.key_len = integer -> integer
2713
2658
  # -->
2714
2659
  # Sets the key length of the cipher. If the cipher is a fixed length cipher
2715
2660
  # then attempting to set the key length to any value other than the fixed value
@@ -2733,7 +2678,7 @@ module OpenSSL
2733
2678
 
2734
2679
  # <!--
2735
2680
  # rdoc-file=ext/openssl/ossl_cipher.c
2736
- # - cipher.padding = 1 or 0
2681
+ # - cipher.padding = integer -> integer
2737
2682
  # -->
2738
2683
  # Enables or disables padding. By default encryption operations are padded using
2739
2684
  # standard block padding and the padding is checked and removed when decrypting.
@@ -2751,16 +2696,19 @@ module OpenSSL
2751
2696
  # -->
2752
2697
  # Generates and sets the key/IV based on a password.
2753
2698
  #
2754
- # **WARNING**: This method is deprecated and should not be used. This method
2755
- # corresponds to EVP_BytesToKey(), a non-standard OpenSSL extension of the
2756
- # legacy PKCS #5 v1.5 key derivation function. See OpenSSL::KDF for other
2757
- # options to derive keys from passwords.
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.
2758
2704
  #
2759
2705
  # ### Parameters
2760
2706
  # * *salt* must be an 8 byte string if provided.
2761
2707
  # * *iterations* is an integer with a default of 2048.
2762
2708
  # * *digest* is a Digest object that defaults to 'MD5'
2763
2709
  #
2710
+ # A minimum of 1000 iterations is recommended.
2711
+ #
2764
2712
  def pkcs5_keyivgen: (String pass, ?String salt, ?Integer iterations, ?String digest) -> void
2765
2713
 
2766
2714
  # <!--
@@ -2807,9 +2755,6 @@ module OpenSSL
2807
2755
  # If *buffer* is given, the encryption/decryption result will be written to it.
2808
2756
  # *buffer* will be resized automatically.
2809
2757
  #
2810
- # **NOTE**: When decrypting using an AEAD cipher, the integrity of the output is
2811
- # not verified until #final has been called.
2812
- #
2813
2758
  def update: (String data, ?String buffer) -> String
2814
2759
 
2815
2760
  private
@@ -2918,7 +2863,7 @@ module OpenSSL
2918
2863
  # configuration. See the value of OpenSSL::Config::DEFAULT_CONFIG_FILE for the
2919
2864
  # location of the file for your host.
2920
2865
  #
2921
- # See also https://docs.openssl.org/master/man5/config/
2866
+ # See also http://www.openssl.org/docs/apps/config.html
2922
2867
  #
2923
2868
  class Config
2924
2869
  include Enumerable[[ String, String, String ]]
@@ -5097,11 +5042,7 @@ module OpenSSL
5097
5042
  end
5098
5043
 
5099
5044
  # <!-- rdoc-file=ext/openssl/ossl.c -->
5100
- # Generic error class for OpenSSL. All error classes in this library inherit
5101
- # from this class.
5102
- #
5103
- # This class indicates that an error was reported by the underlying OpenSSL
5104
- # library.
5045
+ # Generic error, common for all classes under OpenSSL module
5105
5046
  #
5106
5047
  class OpenSSLError < StandardError
5107
5048
  end
@@ -5701,12 +5642,11 @@ module OpenSSL
5701
5642
  def p: () -> BN
5702
5643
 
5703
5644
  # <!--
5704
- # rdoc-file=ext/openssl/lib/openssl/pkey.rb
5645
+ # rdoc-file=ext/openssl/ossl_pkey_dh.c
5705
5646
  # - dh.params -> hash
5706
5647
  # -->
5707
- # Stores all parameters of key to a Hash.
5708
- #
5709
- # The hash has keys 'p', 'q', 'g', 'pub_key', and 'priv_key'.
5648
+ # Stores all parameters of key to the hash INSECURE: PRIVATE INFORMATIONS CAN
5649
+ # LEAK OUT!!! Don't use :-)) (I's up to you)
5710
5650
  #
5711
5651
  def params: () -> Hash[String, BN?]
5712
5652
 
@@ -5858,8 +5798,7 @@ module OpenSSL
5858
5798
  #
5859
5799
  # If called without arguments, an empty instance without any parameter or key
5860
5800
  # components is created. Use #set_pqg to manually set the parameters afterwards
5861
- # (and optionally #set_key to set private and public key components). This form
5862
- # is not compatible with OpenSSL 3.0 or later.
5801
+ # (and optionally #set_key to set private and public key components).
5863
5802
  #
5864
5803
  # If a String is given, tries to parse it as a DER- or PEM- encoded parameters.
5865
5804
  # See also OpenSSL::PKey.read which can parse keys of any kinds.
@@ -5878,15 +5817,14 @@ module OpenSSL
5878
5817
  #
5879
5818
  # Examples:
5880
5819
  # # Creating an instance from scratch
5881
- # # Note that this is deprecated and will result in ArgumentError when
5882
- # # using OpenSSL 3.0 or later.
5820
+ # # Note that this is deprecated and will not work on OpenSSL 3.0 or later.
5883
5821
  # dh = OpenSSL::PKey::DH.new
5884
5822
  # dh.set_pqg(bn_p, nil, bn_g)
5885
5823
  #
5886
5824
  # # Generating a parameters and a key pair
5887
5825
  # dh = OpenSSL::PKey::DH.new(2048) # An alias of OpenSSL::PKey::DH.generate(2048)
5888
5826
  #
5889
- # # Reading DH parameters from a PEM-encoded string
5827
+ # # Reading DH parameters
5890
5828
  # dh_params = OpenSSL::PKey::DH.new(File.read('parameters.pem')) # loads parameters only
5891
5829
  # dh = OpenSSL::PKey.generate_key(dh_params) # generates a key pair
5892
5830
  #
@@ -5998,12 +5936,11 @@ module OpenSSL
5998
5936
  def p: () -> BN
5999
5937
 
6000
5938
  # <!--
6001
- # rdoc-file=ext/openssl/lib/openssl/pkey.rb
5939
+ # rdoc-file=ext/openssl/ossl_pkey_dsa.c
6002
5940
  # - dsa.params -> hash
6003
5941
  # -->
6004
- # Stores all parameters of key to a Hash.
6005
- #
6006
- # The hash has keys 'p', 'q', 'g', 'pub_key', and 'priv_key'.
5942
+ # Stores all parameters of key to the hash INSECURE: PRIVATE INFORMATIONS CAN
5943
+ # LEAK OUT!!! Don't use :-)) (I's up to you)
6007
5944
  #
6008
5945
  def params: () -> Hash[String, BN?]
6009
5946
 
@@ -6253,8 +6190,7 @@ module OpenSSL
6253
6190
  # Creates a new DSA instance by reading an existing key from *string*.
6254
6191
  #
6255
6192
  # If called without arguments, creates a new instance with no key components
6256
- # set. They can be set individually by #set_pqg and #set_key. This form is not
6257
- # compatible with OpenSSL 3.0 or later.
6193
+ # set. They can be set individually by #set_pqg and #set_key.
6258
6194
  #
6259
6195
  # If called with a String, tries to parse as DER or PEM encoding of a DSA key.
6260
6196
  # See also OpenSSL::PKey.read which can parse keys of any kinds.
@@ -6702,10 +6638,9 @@ module OpenSSL
6702
6638
 
6703
6639
  # <!--
6704
6640
  # rdoc-file=ext/openssl/ossl_pkey_ec.c
6705
- # - group.curve_name -> string or nil
6641
+ # - group.curve_name => String
6706
6642
  # -->
6707
- # Returns the curve name (short name) corresponding to this group, or `nil` if
6708
- # OpenSSL does not have an OID associated with the group.
6643
+ # Returns the curve name (sn).
6709
6644
  #
6710
6645
  # See the OpenSSL documentation for EC_GROUP_get_curve_name()
6711
6646
  #
@@ -6915,6 +6850,7 @@ module OpenSSL
6915
6850
  # <!--
6916
6851
  # rdoc-file=ext/openssl/ossl_pkey_ec.c
6917
6852
  # - point.mul(bn1 [, bn2]) => point
6853
+ # - point.mul(bns, points [, bn2]) => point
6918
6854
  # -->
6919
6855
  # Performs elliptic curve point multiplication.
6920
6856
  #
@@ -6922,9 +6858,10 @@ module OpenSSL
6922
6858
  # of the group of *point*. *bn2* may be omitted, and in that case, the result is
6923
6859
  # just `bn1 * point`.
6924
6860
  #
6925
- # Before version 4.0.0, and when compiled with OpenSSL 1.1.1 or older, this
6926
- # method allowed another form:
6927
- # point.mul(bns, points [, bn2]) => point
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]`.
6928
6865
  #
6929
6866
  def mul: (bn bn1, ?bn bn2) -> self
6930
6867
  | (Array[bn] bns, Array[self], ?bn bn2) -> self
@@ -7166,15 +7103,6 @@ module OpenSSL
7166
7103
  # <!-- rdoc-file=ext/openssl/ossl_pkey.c -->
7167
7104
  # Raised when errors occur during PKey#sign or PKey#verify.
7168
7105
  #
7169
- # Before version 4.0.0, OpenSSL::PKey::PKeyError had the following subclasses.
7170
- # These subclasses have been removed and the constants are now defined as
7171
- # aliases of OpenSSL::PKey::PKeyError.
7172
- #
7173
- # * OpenSSL::PKey::DHError
7174
- # * OpenSSL::PKey::DSAError
7175
- # * OpenSSL::PKey::ECError
7176
- # * OpenSSL::PKey::RSAError
7177
- #
7178
7106
  class PKeyError < OpenSSL::OpenSSLError
7179
7107
  end
7180
7108
 
@@ -7282,12 +7210,15 @@ module OpenSSL
7282
7210
  def p: () -> BN?
7283
7211
 
7284
7212
  # <!--
7285
- # rdoc-file=ext/openssl/lib/openssl/pkey.rb
7286
- # - rsa.params -> hash
7213
+ # rdoc-file=ext/openssl/ossl_pkey_rsa.c
7214
+ # - rsa.params => hash
7287
7215
  # -->
7288
- # Stores all parameters of key to a Hash.
7216
+ # THIS METHOD IS INSECURE, PRIVATE INFORMATION CAN LEAK OUT!!!
7289
7217
  #
7290
- # The hash has keys 'n', 'e', 'd', 'p', 'q', 'dmp1', 'dmq1', and 'iqmp'.
7218
+ # Stores all parameters of key to the hash. The hash has keys 'n', 'e', 'd',
7219
+ # 'p', 'q', 'dmp1', 'dmq1', 'iqmp'.
7220
+ #
7221
+ # Don't use :-)) (It's up to you)
7291
7222
  #
7292
7223
  def params: () -> Hash[String, BN?]
7293
7224
 
@@ -7412,7 +7343,7 @@ module OpenSSL
7412
7343
  # Signs *data* using the Probabilistic Signature Scheme (RSA-PSS) and returns
7413
7344
  # the calculated signature.
7414
7345
  #
7415
- # PKeyError will be raised if an error occurs.
7346
+ # RSAError will be raised if an error occurs.
7416
7347
  #
7417
7348
  # See #verify_pss for the verification operation.
7418
7349
  #
@@ -7586,7 +7517,7 @@ module OpenSSL
7586
7517
  # Verifies *data* using the Probabilistic Signature Scheme (RSA-PSS).
7587
7518
  #
7588
7519
  # The return value is `true` if the signature is valid, `false` otherwise.
7589
- # PKeyError will be raised if an error occurs.
7520
+ # RSAError will be raised if an error occurs.
7590
7521
  #
7591
7522
  # See #sign_pss for the signing operation and an example code.
7592
7523
  #
@@ -7620,7 +7551,7 @@ module OpenSSL
7620
7551
  #
7621
7552
  # If called without arguments, creates a new instance with no key components
7622
7553
  # set. They can be set individually by #set_key, #set_factors, and
7623
- # #set_crt_params. This form is not compatible with OpenSSL 3.0 or later.
7554
+ # #set_crt_params.
7624
7555
  #
7625
7556
  # If called with a String, tries to parse as DER or PEM encoding of an RSA key.
7626
7557
  # Note that if *password* is not specified, but the key is encrypted with a
@@ -7655,17 +7586,10 @@ module OpenSSL
7655
7586
  SSLV23_PADDING: Integer
7656
7587
  end
7657
7588
 
7658
- # <!-- rdoc-file=ext/openssl/ossl_pkey.c -->
7659
- # Raised when errors occur during PKey#sign or PKey#verify.
7660
- #
7661
- # Before version 4.0.0, OpenSSL::PKey::PKeyError had the following subclasses.
7662
- # These subclasses have been removed and the constants are now defined as
7663
- # aliases of OpenSSL::PKey::PKeyError.
7664
- #
7665
- # * OpenSSL::PKey::DHError
7666
- # * OpenSSL::PKey::DSAError
7667
- # * OpenSSL::PKey::ECError
7668
- # * OpenSSL::PKey::RSAError
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.
7669
7593
  #
7670
7594
  class RSAError < OpenSSL::PKey::PKeyError
7671
7595
  end
@@ -8105,14 +8029,9 @@ module OpenSSL
8105
8029
  # - ctx.ciphers = [name, ...]
8106
8030
  # - ctx.ciphers = [[name, version, bits, alg_bits], ...]
8107
8031
  # -->
8108
- # Sets the list of available cipher suites for TLS 1.2 and below for this
8109
- # context.
8110
- #
8111
- # Note in a server context some ciphers require the appropriate certificates.
8112
- # For example, an RSA cipher suite can only be chosen when an RSA certificate is
8113
- # available.
8114
- #
8115
- # This method does not affect TLS 1.3 connections. See also #ciphersuites=.
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.
8116
8035
  #
8117
8036
  def ciphers=: (Array[[ String, String, Integer, Integer ]] ciphers) -> void
8118
8037
  | (Array[String] ciphers) -> void
@@ -8148,25 +8067,24 @@ module OpenSSL
8148
8067
  #
8149
8068
  def client_cert_cb=: (^(Session) -> [ X509::Certificate, PKey::PKey ]? client_cert_cb) -> void
8150
8069
 
8151
- # <!-- rdoc-file=ext/openssl/ossl_ssl.c -->
8152
- # Sets the list of supported groups for key agreement for this context.
8153
- #
8154
- # For a TLS client, the list is directly used in the "supported_groups"
8155
- # extension. For a server, the list is used by OpenSSL to determine the set of
8156
- # shared supported groups. OpenSSL will pick the most appropriate one from it.
8157
- #
8158
- # #ecdh_curves= is a deprecated alias for #groups=.
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.
8159
8075
  #
8160
- # See also the man page SSL_CTX_set1_groups_list(3).
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.
8161
8079
  #
8162
8080
  # ### Example
8163
8081
  # ctx1 = OpenSSL::SSL::SSLContext.new
8164
- # ctx1.groups = "X25519:P-256:P-224"
8082
+ # ctx1.ecdh_curves = "X25519:P-256:P-224"
8165
8083
  # svr = OpenSSL::SSL::SSLServer.new(tcp_svr, ctx1)
8166
8084
  # Thread.new { svr.accept }
8167
8085
  #
8168
8086
  # ctx2 = OpenSSL::SSL::SSLContext.new
8169
- # ctx2.groups = "P-256"
8087
+ # ctx2.ecdh_curves = "P-256"
8170
8088
  # cli = OpenSSL::SSL::SSLSocket.new(tcp_sock, ctx2)
8171
8089
  # cli.connect
8172
8090
  #
@@ -8231,7 +8149,7 @@ module OpenSSL
8231
8149
  def key=: (PKey::PKey) -> PKey::PKey
8232
8150
 
8233
8151
  # <!--
8234
- # rdoc-file=ext/openssl/ossl_ssl.c
8152
+ # rdoc-file=ext/openssl/lib/openssl/ssl.rb
8235
8153
  # - ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
8236
8154
  # - ctx.max_version = :TLS1_2
8237
8155
  # - ctx.max_version = nil
@@ -8242,7 +8160,7 @@ module OpenSSL
8242
8160
  def max_version=: (tls_version version) -> tls_version
8243
8161
 
8244
8162
  # <!--
8245
- # rdoc-file=ext/openssl/ossl_ssl.c
8163
+ # rdoc-file=ext/openssl/lib/openssl/ssl.rb
8246
8164
  # - ctx.min_version = OpenSSL::SSL::TLS1_2_VERSION
8247
8165
  # - ctx.min_version = :TLS1_2
8248
8166
  # - ctx.min_version = nil
@@ -8251,6 +8169,9 @@ module OpenSSL
8251
8169
  # may be specified by an integer constant named OpenSSL::SSL::*_VERSION, a
8252
8170
  # Symbol, or `nil` which means "any version".
8253
8171
  #
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
+ #
8254
8175
  # ### Example
8255
8176
  # ctx = OpenSSL::SSL::SSLContext.new
8256
8177
  # ctx.min_version = OpenSSL::SSL::TLS1_1_VERSION
@@ -8660,7 +8581,7 @@ module OpenSSL
8660
8581
  #
8661
8582
  def timeout=: (Integer) -> Integer
8662
8583
 
8663
- # <!-- rdoc-file=ext/openssl/ossl_ssl.c -->
8584
+ # <!-- rdoc-file=ext/openssl/lib/openssl/ssl.rb -->
8664
8585
  # A callback invoked when DH parameters are required for ephemeral DH key
8665
8586
  # exchange.
8666
8587
  #
@@ -8674,7 +8595,7 @@ module OpenSSL
8674
8595
  #
8675
8596
  def tmp_dh_callback: () -> (^(Session, Integer, Integer) -> PKey::DH | nil)
8676
8597
 
8677
- # <!-- rdoc-file=ext/openssl/ossl_ssl.c -->
8598
+ # <!-- rdoc-file=ext/openssl/lib/openssl/ssl.rb -->
8678
8599
  # A callback invoked when DH parameters are required for ephemeral DH key
8679
8600
  # exchange.
8680
8601
  #
@@ -9023,7 +8944,7 @@ module OpenSSL
9023
8944
 
9024
8945
  # <!--
9025
8946
  # rdoc-file=ext/openssl/ossl_ssl.c
9026
- # - ssl.client_ca => [x509name, ...] or nil
8947
+ # - ssl.client_ca => [x509name, ...]
9027
8948
  # -->
9028
8949
  # Returns the list of client CAs. Please note that in contrast to
9029
8950
  # SSLContext#client_ca= no array of X509::Certificate is returned but X509::Name
@@ -9594,33 +9515,65 @@ module OpenSSL
9594
9515
  # fac.additional_certificates = [ inter1, inter2 ]
9595
9516
  # timestamp = fac.create_timestamp(p12.key, p12.certificate, req)
9596
9517
  #
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
+ #
9597
9570
  class Factory
9598
- # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9599
- # Additional certificates apart from the timestamp certificate (e.g.
9600
- # intermediate certificates) to be added to the Response. Must be an Array of
9601
- # OpenSSL::X509::Certificate, or `nil`.
9602
- #
9603
9571
  def additional_certs: () -> Array[X509::Certificate]?
9604
9572
 
9605
- # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9606
- # Additional certificates apart from the timestamp certificate (e.g.
9607
- # intermediate certificates) to be added to the Response. Must be an Array of
9608
- # OpenSSL::X509::Certificate, or `nil`.
9609
- #
9610
9573
  def additional_certs=: (Array[X509::Certificate]? certs) -> Array[X509::Certificate]?
9611
9574
 
9612
- # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9613
- # The list of digest algorithms that the factory is allowed create timestamps
9614
- # for. Known vulnerable or weak algorithms should not be allowed where possible.
9615
- # Must be an Array of String or OpenSSL::Digest subclass instances.
9616
- #
9617
9575
  def allowed_digests: () -> Array[String | Digest]?
9618
9576
 
9619
- # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9620
- # The list of digest algorithms that the factory is allowed create timestamps
9621
- # for. Known vulnerable or weak algorithms should not be allowed where possible.
9622
- # Must be an Array of String or OpenSSL::Digest subclass instances.
9623
- #
9624
9577
  def allowed_digests=: (Array[String | Digest]) -> Array[String | Digest]
9625
9578
 
9626
9579
  # <!--
@@ -9649,48 +9602,16 @@ module OpenSSL
9649
9602
  #
9650
9603
  def create_timestamp: (PKey::PKey key, X509::Certificate cert, Request request) -> Response
9651
9604
 
9652
- # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9653
- # A String representing the default policy object identifier, or `nil`.
9654
- #
9655
- # Request#policy_id will always be preferred over this if present in the
9656
- # Request, only if Request#policy_id is `nil` default_policy will be used. If
9657
- # none of both is present, a TimestampError will be raised when trying to create
9658
- # a Response.
9659
- #
9660
9605
  def default_policy_id: () -> String?
9661
9606
 
9662
- # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9663
- # A String representing the default policy object identifier, or `nil`.
9664
- #
9665
- # Request#policy_id will always be preferred over this if present in the
9666
- # Request, only if Request#policy_id is `nil` default_policy will be used. If
9667
- # none of both is present, a TimestampError will be raised when trying to create
9668
- # a Response.
9669
- #
9670
9607
  def default_policy_id=: (String) -> String
9671
9608
 
9672
- # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9673
- # The Time value to be used in the Response. Must be present for timestamp
9674
- # creation.
9675
- #
9676
9609
  def gen_time: () -> Time?
9677
9610
 
9678
- # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9679
- # The Time value to be used in the Response. Must be present for timestamp
9680
- # creation.
9681
- #
9682
9611
  def gen_time=: (Time) -> Time
9683
9612
 
9684
- # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9685
- # The serial number to be used for timestamp creation. Must be present for
9686
- # timestamp creation. Must be an instance of OpenSSL::BN or Integer.
9687
- #
9688
9613
  def serial_number: () -> Integer?
9689
9614
 
9690
- # <!-- rdoc-file=ext/openssl/ossl_ts.c -->
9691
- # The serial number to be used for timestamp creation. Must be present for
9692
- # timestamp creation. Must be an instance of OpenSSL::BN or Integer.
9693
- #
9694
9615
  def serial_number=: (Integer) -> Integer
9695
9616
  end
9696
9617
 
@@ -10384,10 +10305,8 @@ module OpenSSL
10384
10305
 
10385
10306
  # <!--
10386
10307
  # rdoc-file=ext/openssl/ossl_x509attr.c
10387
- # - attr.oid -> string
10308
+ # - attr.oid => string
10388
10309
  # -->
10389
- # Returns the OID of the attribute. Returns the short name or the dotted decimal
10390
- # notation.
10391
10310
  #
10392
10311
  def oid: () -> String
10393
10312
 
@@ -10549,12 +10468,8 @@ module OpenSSL
10549
10468
 
10550
10469
  # <!--
10551
10470
  # rdoc-file=ext/openssl/ossl_x509crl.c
10552
- # - crl.signature_algorithm -> string
10471
+ # - signature_algorithm()
10553
10472
  # -->
10554
- # Returns the signature algorithm used to sign this CRL.
10555
- #
10556
- # Returns the long name of the signature algorithm, or the dotted decimal
10557
- # notation if OpenSSL does not define a long name for it.
10558
10473
  #
10559
10474
  def signature_algorithm: () -> String
10560
10475
 
@@ -10734,12 +10649,6 @@ module OpenSSL
10734
10649
  # Compares the two certificates. Note that this takes into account all fields,
10735
10650
  # not just the issuer name and the serial number.
10736
10651
  #
10737
- # This method uses X509_cmp() from OpenSSL, which compares certificates based on
10738
- # their cached DER encodings. The comparison can be unreliable if a certificate
10739
- # is incomplete.
10740
- #
10741
- # See also the man page X509_cmp(3).
10742
- #
10743
10652
  def ==: (self other) -> bool
10744
10653
 
10745
10654
  # <!--
@@ -10773,7 +10682,7 @@ module OpenSSL
10773
10682
  def extensions=: (Array[Extension]) -> Array[Extension]
10774
10683
 
10775
10684
  # <!--
10776
- # rdoc-file=ext/openssl/lib/openssl/x509.rb
10685
+ # rdoc-file=ext/openssl/ossl_x509cert.c
10777
10686
  # - inspect()
10778
10687
  # -->
10779
10688
  #
@@ -10867,12 +10776,6 @@ module OpenSSL
10867
10776
  # rdoc-file=ext/openssl/ossl_x509cert.c
10868
10777
  # - cert.signature_algorithm => string
10869
10778
  # -->
10870
- # Returns the signature algorithm used to sign this certificate. This returns
10871
- # the algorithm name found in the TBSCertificate structure, not the outer
10872
- # Certificate structure.
10873
- #
10874
- # Returns the long name of the signature algorithm, or the dotted decimal
10875
- # notation if OpenSSL does not define a long name for it.
10876
10779
  #
10877
10780
  def signature_algorithm: () -> String
10878
10781
 
@@ -10990,10 +10893,8 @@ module OpenSSL
10990
10893
 
10991
10894
  # <!--
10992
10895
  # rdoc-file=ext/openssl/ossl_x509ext.c
10993
- # - ext.oid -> string
10896
+ # - oid()
10994
10897
  # -->
10995
- # Returns the OID of the extension. Returns the short name or the dotted decimal
10996
- # notation.
10997
10898
  #
10998
10899
  def oid: () -> String
10999
10900
 
@@ -11646,12 +11547,8 @@ module OpenSSL
11646
11547
 
11647
11548
  # <!--
11648
11549
  # rdoc-file=ext/openssl/ossl_x509req.c
11649
- # - req.signature_algorithm -> string
11550
+ # - signature_algorithm()
11650
11551
  # -->
11651
- # Returns the signature algorithm used to sign this request.
11652
- #
11653
- # Returns the long name of the signature algorithm, or the dotted decimal
11654
- # notation if OpenSSL does not define a long name for it.
11655
11552
  #
11656
11553
  def signature_algorithm: () -> String
11657
11554