rbs 3.3.2 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -5
  3. data/.github/workflows/ruby.yml +7 -8
  4. data/.github/workflows/typecheck.yml +37 -0
  5. data/CHANGELOG.md +65 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +11 -11
  8. data/README.md +1 -0
  9. data/Rakefile +2 -2
  10. data/Steepfile +2 -2
  11. data/core/array.rbs +19 -49
  12. data/core/basic_object.rbs +2 -2
  13. data/core/comparable.rbs +17 -8
  14. data/core/complex.rbs +82 -43
  15. data/core/data.rbs +2 -4
  16. data/core/dir.rbs +635 -295
  17. data/core/enumerable.rbs +11 -18
  18. data/core/enumerator.rbs +37 -31
  19. data/core/errors.rbs +4 -0
  20. data/core/false_class.rbs +34 -15
  21. data/core/fiber.rbs +23 -0
  22. data/core/file.rbs +329 -120
  23. data/core/float.rbs +17 -32
  24. data/core/gc.rbs +17 -11
  25. data/core/hash.rbs +22 -44
  26. data/core/integer.rbs +82 -113
  27. data/core/io/buffer.rbs +90 -47
  28. data/core/io.rbs +54 -121
  29. data/core/kernel.rbs +442 -489
  30. data/core/match_data.rbs +55 -56
  31. data/core/module.rbs +45 -1
  32. data/core/nil_class.rbs +98 -35
  33. data/core/numeric.rbs +22 -32
  34. data/core/object_space/weak_key_map.rbs +102 -0
  35. data/core/process.rbs +1242 -655
  36. data/core/ractor.rbs +139 -120
  37. data/core/range.rbs +100 -4
  38. data/core/rational.rbs +0 -4
  39. data/core/rbs/unnamed/argf.rbs +16 -8
  40. data/core/rbs/unnamed/env_class.rbs +0 -24
  41. data/core/refinement.rbs +8 -0
  42. data/core/regexp.rbs +1149 -598
  43. data/core/ruby_vm.rbs +126 -12
  44. data/core/rubygems/platform.rbs +9 -0
  45. data/core/rubygems/rubygems.rbs +1 -1
  46. data/core/rubygems/version.rbs +5 -1
  47. data/core/set.rbs +20 -22
  48. data/core/signal.rbs +4 -4
  49. data/core/string.rbs +283 -230
  50. data/core/string_io.rbs +2 -14
  51. data/core/struct.rbs +404 -24
  52. data/core/symbol.rbs +1 -19
  53. data/core/thread.rbs +29 -12
  54. data/core/time.rbs +227 -104
  55. data/core/trace_point.rbs +2 -5
  56. data/core/true_class.rbs +54 -21
  57. data/core/warning.rbs +14 -11
  58. data/docs/data_and_struct.md +29 -0
  59. data/docs/gem.md +58 -0
  60. data/docs/syntax.md +3 -5
  61. data/docs/tools.md +1 -0
  62. data/ext/rbs_extension/lexer.c +643 -559
  63. data/ext/rbs_extension/lexer.re +5 -1
  64. data/ext/rbs_extension/parser.c +12 -3
  65. data/ext/rbs_extension/unescape.c +7 -47
  66. data/lib/rbs/cli/diff.rb +4 -1
  67. data/lib/rbs/cli/validate.rb +280 -0
  68. data/lib/rbs/cli.rb +2 -194
  69. data/lib/rbs/collection/config.rb +5 -6
  70. data/lib/rbs/collection/sources/git.rb +1 -1
  71. data/lib/rbs/collection.rb +1 -0
  72. data/lib/rbs/diff.rb +7 -4
  73. data/lib/rbs/errors.rb +11 -0
  74. data/lib/rbs/test/errors.rb +10 -2
  75. data/lib/rbs/test/guaranteed.rb +2 -3
  76. data/lib/rbs/test/type_check.rb +15 -10
  77. data/lib/rbs/test.rb +3 -3
  78. data/lib/rbs/types.rb +29 -0
  79. data/lib/rbs/unit_test/convertibles.rb +176 -0
  80. data/lib/rbs/unit_test/spy.rb +136 -0
  81. data/lib/rbs/unit_test/type_assertions.rb +341 -0
  82. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  83. data/lib/rbs/unit_test.rb +6 -0
  84. data/lib/rbs/version.rb +1 -1
  85. data/sig/cli/validate.rbs +43 -0
  86. data/sig/diff.rbs +3 -1
  87. data/sig/errors.rbs +8 -0
  88. data/sig/rbs.rbs +1 -1
  89. data/sig/test/errors.rbs +52 -0
  90. data/sig/test/guranteed.rbs +9 -0
  91. data/sig/test/type_check.rbs +19 -0
  92. data/sig/test.rbs +82 -0
  93. data/sig/types.rbs +6 -1
  94. data/sig/unit_test/convertibles.rbs +154 -0
  95. data/sig/unit_test/spy.rbs +28 -0
  96. data/sig/unit_test/type_assertions.rbs +194 -0
  97. data/sig/unit_test/with_aliases.rbs +136 -0
  98. data/stdlib/base64/0/base64.rbs +307 -45
  99. data/stdlib/bigdecimal/0/big_decimal.rbs +35 -15
  100. data/stdlib/coverage/0/coverage.rbs +2 -2
  101. data/stdlib/csv/0/csv.rbs +25 -55
  102. data/stdlib/date/0/date.rbs +1 -43
  103. data/stdlib/date/0/date_time.rbs +1 -13
  104. data/stdlib/delegate/0/delegator.rbs +186 -0
  105. data/stdlib/delegate/0/kernel.rbs +47 -0
  106. data/stdlib/delegate/0/simple_delegator.rbs +98 -0
  107. data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -1
  108. data/stdlib/erb/0/erb.rbs +2 -2
  109. data/stdlib/fileutils/0/fileutils.rbs +0 -19
  110. data/stdlib/io-console/0/io-console.rbs +12 -1
  111. data/stdlib/ipaddr/0/ipaddr.rbs +2 -1
  112. data/stdlib/json/0/json.rbs +320 -81
  113. data/stdlib/logger/0/logger.rbs +9 -5
  114. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +6 -6
  115. data/stdlib/monitor/0/monitor.rbs +78 -0
  116. data/stdlib/net-http/0/net-http.rbs +1880 -543
  117. data/stdlib/objspace/0/objspace.rbs +19 -13
  118. data/stdlib/openssl/0/openssl.rbs +508 -127
  119. data/stdlib/optparse/0/optparse.rbs +25 -11
  120. data/stdlib/pathname/0/pathname.rbs +1 -1
  121. data/stdlib/pp/0/pp.rbs +2 -5
  122. data/stdlib/prettyprint/0/prettyprint.rbs +2 -2
  123. data/stdlib/pstore/0/pstore.rbs +2 -4
  124. data/stdlib/rdoc/0/comment.rbs +1 -2
  125. data/stdlib/resolv/0/resolv.rbs +4 -2
  126. data/stdlib/socket/0/socket.rbs +2 -2
  127. data/stdlib/socket/0/unix_socket.rbs +2 -2
  128. data/stdlib/strscan/0/string_scanner.rbs +3 -2
  129. data/stdlib/tempfile/0/tempfile.rbs +1 -1
  130. data/stdlib/uri/0/common.rbs +245 -123
  131. metadata +24 -4
  132. data/lib/rbs/test/spy.rb +0 -6
@@ -20,23 +20,21 @@
20
20
  #
21
21
  # key = OpenSSL::PKey::RSA.new 2048
22
22
  #
23
- # open 'private_key.pem', 'w' do |io| io.write key.to_pem end
24
- # open 'public_key.pem', 'w' do |io| io.write key.public_key.to_pem end
23
+ # File.write 'private_key.pem', key.private_to_pem
24
+ # File.write 'public_key.pem', key.public_to_pem
25
25
  #
26
26
  # ### Exporting a Key
27
27
  #
28
28
  # Keys saved to disk without encryption are not secure as anyone who gets ahold
29
29
  # of the key may use it unless it is encrypted. In order to securely export a
30
- # key you may export it with a pass phrase.
30
+ # key you may export it with a password.
31
31
  #
32
32
  # cipher = OpenSSL::Cipher.new 'aes-256-cbc'
33
- # pass_phrase = 'my secure pass phrase goes here'
33
+ # password = 'my secure password goes here'
34
34
  #
35
- # key_secure = key.export cipher, pass_phrase
35
+ # key_secure = key.private_to_pem cipher, password
36
36
  #
37
- # open 'private.secure.pem', 'w' do |io|
38
- # io.write key_secure
39
- # end
37
+ # File.write 'private.secure.pem', key_secure
40
38
  #
41
39
  # OpenSSL::Cipher.ciphers returns a list of available ciphers.
42
40
  #
@@ -56,13 +54,13 @@
56
54
  #
57
55
  # ### Loading an Encrypted Key
58
56
  #
59
- # OpenSSL will prompt you for your pass phrase when loading an encrypted key. If
60
- # you will not be able to type in the pass phrase you may provide it when
61
- # loading the key:
57
+ # OpenSSL will prompt you for your password when loading an encrypted key. If
58
+ # you will not be able to type in the password you may provide it when loading
59
+ # the key:
62
60
  #
63
61
  # key4_pem = File.read 'private.secure.pem'
64
- # pass_phrase = 'my secure pass phrase goes here'
65
- # key4 = OpenSSL::PKey.read key4_pem, pass_phrase
62
+ # password = 'my secure password goes here'
63
+ # key4 = OpenSSL::PKey.read key4_pem, password
66
64
  #
67
65
  # ## RSA Encryption
68
66
  #
@@ -175,44 +173,6 @@
175
173
  # decrypted = cipher.update encrypted
176
174
  # decrypted << cipher.final
177
175
  #
178
- # ## PKCS #5 Password-based Encryption
179
- #
180
- # PKCS #5 is a password-based encryption standard documented at
181
- # [RFC2898](http://www.ietf.org/rfc/rfc2898.txt). It allows a short password or
182
- # passphrase to be used to create a secure encryption key. If possible, PBKDF2
183
- # as described above should be used if the circumstances allow it.
184
- #
185
- # PKCS #5 uses a Cipher, a pass phrase and a salt to generate an encryption key.
186
- #
187
- # pass_phrase = 'my secure pass phrase goes here'
188
- # salt = '8 octets'
189
- #
190
- # ### Encryption
191
- #
192
- # First set up the cipher for encryption
193
- #
194
- # encryptor = OpenSSL::Cipher.new 'aes-256-cbc'
195
- # encryptor.encrypt
196
- # encryptor.pkcs5_keyivgen pass_phrase, salt
197
- #
198
- # Then pass the data you want to encrypt through
199
- #
200
- # encrypted = encryptor.update 'top secret document'
201
- # encrypted << encryptor.final
202
- #
203
- # ### Decryption
204
- #
205
- # Use a new Cipher instance set up for decryption
206
- #
207
- # decryptor = OpenSSL::Cipher.new 'aes-256-cbc'
208
- # decryptor.decrypt
209
- # decryptor.pkcs5_keyivgen pass_phrase, salt
210
- #
211
- # Then pass the data you want to decrypt through
212
- #
213
- # plain = decryptor.update encrypted
214
- # plain << decryptor.final
215
- #
216
176
  # ## X509 Certificates
217
177
  #
218
178
  # ### Creating a Certificate
@@ -290,12 +250,12 @@
290
250
  # not readable by other users.
291
251
  #
292
252
  # ca_key = OpenSSL::PKey::RSA.new 2048
293
- # pass_phrase = 'my secure pass phrase goes here'
253
+ # password = 'my secure password goes here'
294
254
  #
295
- # cipher = OpenSSL::Cipher.new 'aes-256-cbc'
255
+ # cipher = 'aes-256-cbc'
296
256
  #
297
257
  # open 'ca_key.pem', 'w', 0400 do |io|
298
- # io.write ca_key.export(cipher, pass_phrase)
258
+ # io.write ca_key.private_to_pem(cipher, password)
299
259
  # end
300
260
  #
301
261
  # ### CA Certificate
@@ -584,7 +544,18 @@ module OpenSSL
584
544
  OPENSSL_VERSION: String
585
545
 
586
546
  # <!-- rdoc-file=ext/openssl/ossl.c -->
587
- # Version number of OpenSSL the ruby OpenSSL extension was built with (base 16)
547
+ # Version number of OpenSSL the ruby OpenSSL extension was built with (base 16).
548
+ # The formats are below.
549
+ #
550
+ # OpenSSL 3
551
+ # : `0xMNN00PP0 (major minor 00 patch 0)`
552
+ # OpenSSL before 3
553
+ # : `0xMNNFFPPS (major minor fix patch status)`
554
+ # LibreSSL
555
+ # : `0x20000000 (fixed value)`
556
+ #
557
+ #
558
+ # See also the man page OPENSSL_VERSION_NUMBER(3).
588
559
  #
589
560
  OPENSSL_VERSION_NUMBER: Integer
590
561
 
@@ -812,7 +783,7 @@ module OpenSSL
812
783
  # puts "Header length: #{header_len} Tag: #{tag} Tag class: #{tag_class} Constructed: #{constructed}"
813
784
  # end
814
785
  #
815
- def self.traverse: (String | _ToDer der) { (::Integer, ::Integer, ::Integer, ::Integer, bool, tag_class, ::Integer) -> void } -> void
786
+ def self.traverse: (String | _ToDer der) { ([::Integer, ::Integer, ::Integer, ::Integer, bool, tag_class, ::Integer]) -> void } -> void
816
787
 
817
788
  BIT_STRING: Integer
818
789
 
@@ -3221,14 +3192,10 @@ module OpenSSL
3221
3192
  # Return the hash value computed with *name* Digest. *name* is either the long
3222
3193
  # name or short name of a supported digest algorithm.
3223
3194
  #
3224
- # ### Examples
3195
+ # ### Example
3225
3196
  #
3226
3197
  # OpenSSL::Digest.digest("SHA256", "abc")
3227
3198
  #
3228
- # which is equivalent to:
3229
- #
3230
- # OpenSSL::Digest.digest('SHA256', "abc")
3231
- #
3232
3199
  def self.digest: (String name, String data) -> String
3233
3200
 
3234
3201
  public
@@ -3998,7 +3965,7 @@ module OpenSSL
3998
3965
  #
3999
3966
  # ### Parameters
4000
3967
  # pass
4001
- # : The passphrase.
3968
+ # : The password.
4002
3969
  # salt
4003
3970
  # : The salt. Salts prevent attacks based on dictionaries of common passwords
4004
3971
  # and attacks based on rainbow tables. It is a public value that can be
@@ -4312,7 +4279,7 @@ module OpenSSL
4312
4279
  # require 'net/http'
4313
4280
  #
4314
4281
  # http_response =
4315
- # Net::HTTP.start ocsp_uri.hostname, ocsp.port do |http|
4282
+ # Net::HTTP.start ocsp_uri.hostname, ocsp_uri.port do |http|
4316
4283
  # http.post ocsp_uri.path, request.to_der,
4317
4284
  # 'content-type' => 'application/ocsp-request'
4318
4285
  # end
@@ -5637,9 +5604,20 @@ module OpenSSL
5637
5604
  # - dh.to_pem -> aString
5638
5605
  # - dh.to_s -> aString
5639
5606
  # -->
5640
- # Encodes this DH to its PEM encoding. Note that any existing per-session
5641
- # public/private keys will **not** get encoded, just the Diffie-Hellman
5642
- # parameters will be encoded.
5607
+ # Serializes the DH parameters to a PEM-encoding.
5608
+ #
5609
+ # Note that any existing per-session public/private keys will **not** get
5610
+ # encoded, just the Diffie-Hellman parameters will be encoded.
5611
+ #
5612
+ # PEM-encoded parameters will look like:
5613
+ #
5614
+ # -----BEGIN DH PARAMETERS-----
5615
+ # [...]
5616
+ # -----END DH PARAMETERS-----
5617
+ #
5618
+ # See also #public_to_pem (X.509 SubjectPublicKeyInfo) and #private_to_pem (PKCS
5619
+ # #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) for serialization with the
5620
+ # private or public key components.
5643
5621
  #
5644
5622
  def export: () -> String
5645
5623
 
@@ -5765,23 +5743,50 @@ module OpenSSL
5765
5743
  # rdoc-file=ext/openssl/ossl_pkey_dh.c
5766
5744
  # - dh.to_der -> aString
5767
5745
  # -->
5768
- # Encodes this DH to its DER encoding. Note that any existing per-session
5769
- # public/private keys will **not** get encoded, just the Diffie-Hellman
5770
- # parameters will be encoded.
5746
+ # Serializes the DH parameters to a DER-encoding
5747
+ #
5748
+ # Note that any existing per-session public/private keys will **not** get
5749
+ # encoded, just the Diffie-Hellman parameters will be encoded.
5750
+ #
5751
+ # See also #public_to_der (X.509 SubjectPublicKeyInfo) and #private_to_der (PKCS
5752
+ # #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) for serialization with the
5753
+ # private or public key components.
5771
5754
  #
5772
5755
  def to_der: () -> String
5773
5756
 
5774
5757
  # <!-- rdoc-file=ext/openssl/ossl_pkey_dh.c -->
5775
- # Encodes this DH to its PEM encoding. Note that any existing per-session
5776
- # public/private keys will **not** get encoded, just the Diffie-Hellman
5777
- # parameters will be encoded.
5758
+ # Serializes the DH parameters to a PEM-encoding.
5759
+ #
5760
+ # Note that any existing per-session public/private keys will **not** get
5761
+ # encoded, just the Diffie-Hellman parameters will be encoded.
5762
+ #
5763
+ # PEM-encoded parameters will look like:
5764
+ #
5765
+ # -----BEGIN DH PARAMETERS-----
5766
+ # [...]
5767
+ # -----END DH PARAMETERS-----
5768
+ #
5769
+ # See also #public_to_pem (X.509 SubjectPublicKeyInfo) and #private_to_pem (PKCS
5770
+ # #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) for serialization with the
5771
+ # private or public key components.
5778
5772
  #
5779
5773
  alias to_pem export
5780
5774
 
5781
5775
  # <!-- rdoc-file=ext/openssl/ossl_pkey_dh.c -->
5782
- # Encodes this DH to its PEM encoding. Note that any existing per-session
5783
- # public/private keys will **not** get encoded, just the Diffie-Hellman
5784
- # parameters will be encoded.
5776
+ # Serializes the DH parameters to a PEM-encoding.
5777
+ #
5778
+ # Note that any existing per-session public/private keys will **not** get
5779
+ # encoded, just the Diffie-Hellman parameters will be encoded.
5780
+ #
5781
+ # PEM-encoded parameters will look like:
5782
+ #
5783
+ # -----BEGIN DH PARAMETERS-----
5784
+ # [...]
5785
+ # -----END DH PARAMETERS-----
5786
+ #
5787
+ # See also #public_to_pem (X.509 SubjectPublicKeyInfo) and #private_to_pem (PKCS
5788
+ # #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) for serialization with the
5789
+ # private or public key components.
5785
5790
  #
5786
5791
  alias to_s export
5787
5792
 
@@ -5885,16 +5890,54 @@ module OpenSSL
5885
5890
  # - dsa.to_pem([cipher, password]) -> aString
5886
5891
  # - dsa.to_s([cipher, password]) -> aString
5887
5892
  # -->
5888
- # Encodes this DSA to its PEM encoding.
5893
+ # Serializes a private or public key to a PEM-encoding.
5889
5894
  #
5890
- # ### Parameters
5891
- # * *cipher* is an OpenSSL::Cipher.
5892
- # * *password* is a string containing your password.
5895
+ # When the key contains public components only
5896
+ # : Serializes it into an X.509 SubjectPublicKeyInfo. The parameters *cipher*
5897
+ # and *password* are ignored.
5893
5898
  #
5899
+ # A PEM-encoded key will look like:
5894
5900
  #
5895
- # ### Examples
5896
- # DSA.to_pem -> aString
5897
- # DSA.to_pem(cipher, 'mypassword') -> aString
5901
+ # -----BEGIN PUBLIC KEY-----
5902
+ # [...]
5903
+ # -----END PUBLIC KEY-----
5904
+ #
5905
+ # Consider using #public_to_pem instead. This serializes the key into an
5906
+ # X.509 SubjectPublicKeyInfo regardless of whether it is a public key or a
5907
+ # private key.
5908
+ #
5909
+ # When the key contains private components, and no parameters are given
5910
+ # : Serializes it into a traditional OpenSSL DSAPrivateKey.
5911
+ #
5912
+ # A PEM-encoded key will look like:
5913
+ #
5914
+ # -----BEGIN DSA PRIVATE KEY-----
5915
+ # [...]
5916
+ # -----END DSA PRIVATE KEY-----
5917
+ #
5918
+ # When the key contains private components, and *cipher* and *password* are given
5919
+ # : Serializes it into a traditional OpenSSL DSAPrivateKey and encrypts it in
5920
+ # OpenSSL's traditional PEM encryption format. *cipher* must be a cipher
5921
+ # name understood by OpenSSL::Cipher.new or an instance of OpenSSL::Cipher.
5922
+ #
5923
+ # An encrypted PEM-encoded key will look like:
5924
+ #
5925
+ # -----BEGIN DSA PRIVATE KEY-----
5926
+ # Proc-Type: 4,ENCRYPTED
5927
+ # DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
5928
+ #
5929
+ # [...]
5930
+ # -----END DSA PRIVATE KEY-----
5931
+ #
5932
+ # Note that this format uses MD5 to derive the encryption key, and hence
5933
+ # will not be available on FIPS-compliant systems.
5934
+ #
5935
+ #
5936
+ # **This method is kept for compatibility.** This should only be used when the
5937
+ # traditional, non-standard OpenSSL format is required.
5938
+ #
5939
+ # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
5940
+ # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
5898
5941
  #
5899
5942
  def export: (String cipher, String password) -> String
5900
5943
  | () -> String
@@ -6018,35 +6061,118 @@ module OpenSSL
6018
6061
  # rdoc-file=ext/openssl/ossl_pkey_dsa.c
6019
6062
  # - dsa.to_der -> aString
6020
6063
  # -->
6021
- # Encodes this DSA to its DER encoding.
6064
+ # Serializes a private or public key to a DER-encoding.
6065
+ #
6066
+ # See #to_pem for details.
6067
+ #
6068
+ # **This method is kept for compatibility.** This should only be used when the
6069
+ # traditional, non-standard OpenSSL format is required.
6070
+ #
6071
+ # Consider using #public_to_der or #private_to_der instead.
6022
6072
  #
6023
6073
  def to_der: () -> String
6024
6074
 
6025
6075
  # <!-- rdoc-file=ext/openssl/ossl_pkey_dsa.c -->
6026
- # Encodes this DSA to its PEM encoding.
6076
+ # Serializes a private or public key to a PEM-encoding.
6027
6077
  #
6028
- # ### Parameters
6029
- # * *cipher* is an OpenSSL::Cipher.
6030
- # * *password* is a string containing your password.
6078
+ # When the key contains public components only
6079
+ # : Serializes it into an X.509 SubjectPublicKeyInfo. The parameters *cipher*
6080
+ # and *password* are ignored.
6031
6081
  #
6082
+ # A PEM-encoded key will look like:
6032
6083
  #
6033
- # ### Examples
6034
- # DSA.to_pem -> aString
6035
- # DSA.to_pem(cipher, 'mypassword') -> aString
6084
+ # -----BEGIN PUBLIC KEY-----
6085
+ # [...]
6086
+ # -----END PUBLIC KEY-----
6087
+ #
6088
+ # Consider using #public_to_pem instead. This serializes the key into an
6089
+ # X.509 SubjectPublicKeyInfo regardless of whether it is a public key or a
6090
+ # private key.
6091
+ #
6092
+ # When the key contains private components, and no parameters are given
6093
+ # : Serializes it into a traditional OpenSSL DSAPrivateKey.
6094
+ #
6095
+ # A PEM-encoded key will look like:
6096
+ #
6097
+ # -----BEGIN DSA PRIVATE KEY-----
6098
+ # [...]
6099
+ # -----END DSA PRIVATE KEY-----
6100
+ #
6101
+ # When the key contains private components, and *cipher* and *password* are given
6102
+ # : Serializes it into a traditional OpenSSL DSAPrivateKey and encrypts it in
6103
+ # OpenSSL's traditional PEM encryption format. *cipher* must be a cipher
6104
+ # name understood by OpenSSL::Cipher.new or an instance of OpenSSL::Cipher.
6105
+ #
6106
+ # An encrypted PEM-encoded key will look like:
6107
+ #
6108
+ # -----BEGIN DSA PRIVATE KEY-----
6109
+ # Proc-Type: 4,ENCRYPTED
6110
+ # DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
6111
+ #
6112
+ # [...]
6113
+ # -----END DSA PRIVATE KEY-----
6114
+ #
6115
+ # Note that this format uses MD5 to derive the encryption key, and hence
6116
+ # will not be available on FIPS-compliant systems.
6117
+ #
6118
+ #
6119
+ # **This method is kept for compatibility.** This should only be used when the
6120
+ # traditional, non-standard OpenSSL format is required.
6121
+ #
6122
+ # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
6123
+ # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
6036
6124
  #
6037
6125
  alias to_pem export
6038
6126
 
6039
6127
  # <!-- rdoc-file=ext/openssl/ossl_pkey_dsa.c -->
6040
- # Encodes this DSA to its PEM encoding.
6128
+ # Serializes a private or public key to a PEM-encoding.
6041
6129
  #
6042
- # ### Parameters
6043
- # * *cipher* is an OpenSSL::Cipher.
6044
- # * *password* is a string containing your password.
6130
+ # When the key contains public components only
6131
+ # : Serializes it into an X.509 SubjectPublicKeyInfo. The parameters *cipher*
6132
+ # and *password* are ignored.
6045
6133
  #
6134
+ # A PEM-encoded key will look like:
6046
6135
  #
6047
- # ### Examples
6048
- # DSA.to_pem -> aString
6049
- # DSA.to_pem(cipher, 'mypassword') -> aString
6136
+ # -----BEGIN PUBLIC KEY-----
6137
+ # [...]
6138
+ # -----END PUBLIC KEY-----
6139
+ #
6140
+ # Consider using #public_to_pem instead. This serializes the key into an
6141
+ # X.509 SubjectPublicKeyInfo regardless of whether it is a public key or a
6142
+ # private key.
6143
+ #
6144
+ # When the key contains private components, and no parameters are given
6145
+ # : Serializes it into a traditional OpenSSL DSAPrivateKey.
6146
+ #
6147
+ # A PEM-encoded key will look like:
6148
+ #
6149
+ # -----BEGIN DSA PRIVATE KEY-----
6150
+ # [...]
6151
+ # -----END DSA PRIVATE KEY-----
6152
+ #
6153
+ # When the key contains private components, and *cipher* and *password* are given
6154
+ # : Serializes it into a traditional OpenSSL DSAPrivateKey and encrypts it in
6155
+ # OpenSSL's traditional PEM encryption format. *cipher* must be a cipher
6156
+ # name understood by OpenSSL::Cipher.new or an instance of OpenSSL::Cipher.
6157
+ #
6158
+ # An encrypted PEM-encoded key will look like:
6159
+ #
6160
+ # -----BEGIN DSA PRIVATE KEY-----
6161
+ # Proc-Type: 4,ENCRYPTED
6162
+ # DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
6163
+ #
6164
+ # [...]
6165
+ # -----END DSA PRIVATE KEY-----
6166
+ #
6167
+ # Note that this format uses MD5 to derive the encryption key, and hence
6168
+ # will not be available on FIPS-compliant systems.
6169
+ #
6170
+ #
6171
+ # **This method is kept for compatibility.** This should only be used when the
6172
+ # traditional, non-standard OpenSSL format is required.
6173
+ #
6174
+ # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
6175
+ # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
6050
6176
  #
6051
6177
  alias to_s export
6052
6178
 
@@ -6197,13 +6323,57 @@ module OpenSSL
6197
6323
 
6198
6324
  # <!--
6199
6325
  # rdoc-file=ext/openssl/ossl_pkey_ec.c
6200
- # - key.export([cipher, pass_phrase]) => String
6201
- # - key.to_pem([cipher, pass_phrase]) => String
6326
+ # - key.export([cipher, password]) => String
6327
+ # - key.to_pem([cipher, password]) => String
6202
6328
  # -->
6203
- # Outputs the EC key in PEM encoding. If *cipher* and *pass_phrase* are given
6204
- # they will be used to encrypt the key. *cipher* must be an OpenSSL::Cipher
6205
- # instance. Note that encryption will only be effective for a private key,
6206
- # public keys will always be encoded in plain text.
6329
+ # Serializes a private or public key to a PEM-encoding.
6330
+ #
6331
+ # When the key contains public components only
6332
+ # : Serializes it into an X.509 SubjectPublicKeyInfo. The parameters *cipher*
6333
+ # and *password* are ignored.
6334
+ #
6335
+ # A PEM-encoded key will look like:
6336
+ #
6337
+ # -----BEGIN PUBLIC KEY-----
6338
+ # [...]
6339
+ # -----END PUBLIC KEY-----
6340
+ #
6341
+ # Consider using #public_to_pem instead. This serializes the key into an
6342
+ # X.509 SubjectPublicKeyInfo regardless of whether it is a public key or a
6343
+ # private key.
6344
+ #
6345
+ # When the key contains private components, and no parameters are given
6346
+ # : Serializes it into a SEC 1/RFC 5915 ECPrivateKey.
6347
+ #
6348
+ # A PEM-encoded key will look like:
6349
+ #
6350
+ # -----BEGIN EC PRIVATE KEY-----
6351
+ # [...]
6352
+ # -----END EC PRIVATE KEY-----
6353
+ #
6354
+ # When the key contains private components, and *cipher* and *password* are given
6355
+ # : Serializes it into a SEC 1/RFC 5915 ECPrivateKey and encrypts it in
6356
+ # OpenSSL's traditional PEM encryption format. *cipher* must be a cipher
6357
+ # name understood by OpenSSL::Cipher.new or an instance of OpenSSL::Cipher.
6358
+ #
6359
+ # An encrypted PEM-encoded key will look like:
6360
+ #
6361
+ # -----BEGIN EC PRIVATE KEY-----
6362
+ # Proc-Type: 4,ENCRYPTED
6363
+ # DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
6364
+ #
6365
+ # [...]
6366
+ # -----END EC PRIVATE KEY-----
6367
+ #
6368
+ # Note that this format uses MD5 to derive the encryption key, and hence
6369
+ # will not be available on FIPS-compliant systems.
6370
+ #
6371
+ #
6372
+ # **This method is kept for compatibility.** This should only be used when the
6373
+ # SEC 1/RFC 5915 ECPrivateKey format is required.
6374
+ #
6375
+ # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
6376
+ # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
6207
6377
  #
6208
6378
  def export: (String cipher, String password) -> String
6209
6379
  | () -> String
@@ -6321,15 +6491,66 @@ module OpenSSL
6321
6491
  # rdoc-file=ext/openssl/ossl_pkey_ec.c
6322
6492
  # - key.to_der => String
6323
6493
  # -->
6324
- # See the OpenSSL documentation for i2d_ECPrivateKey_bio()
6494
+ # Serializes a private or public key to a DER-encoding.
6495
+ #
6496
+ # See #to_pem for details.
6497
+ #
6498
+ # **This method is kept for compatibility.** This should only be used when the
6499
+ # SEC 1/RFC 5915 ECPrivateKey format is required.
6500
+ #
6501
+ # Consider using #public_to_der or #private_to_der instead.
6325
6502
  #
6326
6503
  def to_der: () -> String
6327
6504
 
6328
6505
  # <!-- rdoc-file=ext/openssl/ossl_pkey_ec.c -->
6329
- # Outputs the EC key in PEM encoding. If *cipher* and *pass_phrase* are given
6330
- # they will be used to encrypt the key. *cipher* must be an OpenSSL::Cipher
6331
- # instance. Note that encryption will only be effective for a private key,
6332
- # public keys will always be encoded in plain text.
6506
+ # Serializes a private or public key to a PEM-encoding.
6507
+ #
6508
+ # When the key contains public components only
6509
+ # : Serializes it into an X.509 SubjectPublicKeyInfo. The parameters *cipher*
6510
+ # and *password* are ignored.
6511
+ #
6512
+ # A PEM-encoded key will look like:
6513
+ #
6514
+ # -----BEGIN PUBLIC KEY-----
6515
+ # [...]
6516
+ # -----END PUBLIC KEY-----
6517
+ #
6518
+ # Consider using #public_to_pem instead. This serializes the key into an
6519
+ # X.509 SubjectPublicKeyInfo regardless of whether it is a public key or a
6520
+ # private key.
6521
+ #
6522
+ # When the key contains private components, and no parameters are given
6523
+ # : Serializes it into a SEC 1/RFC 5915 ECPrivateKey.
6524
+ #
6525
+ # A PEM-encoded key will look like:
6526
+ #
6527
+ # -----BEGIN EC PRIVATE KEY-----
6528
+ # [...]
6529
+ # -----END EC PRIVATE KEY-----
6530
+ #
6531
+ # When the key contains private components, and *cipher* and *password* are given
6532
+ # : Serializes it into a SEC 1/RFC 5915 ECPrivateKey and encrypts it in
6533
+ # OpenSSL's traditional PEM encryption format. *cipher* must be a cipher
6534
+ # name understood by OpenSSL::Cipher.new or an instance of OpenSSL::Cipher.
6535
+ #
6536
+ # An encrypted PEM-encoded key will look like:
6537
+ #
6538
+ # -----BEGIN EC PRIVATE KEY-----
6539
+ # Proc-Type: 4,ENCRYPTED
6540
+ # DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
6541
+ #
6542
+ # [...]
6543
+ # -----END EC PRIVATE KEY-----
6544
+ #
6545
+ # Note that this format uses MD5 to derive the encryption key, and hence
6546
+ # will not be available on FIPS-compliant systems.
6547
+ #
6548
+ #
6549
+ # **This method is kept for compatibility.** This should only be used when the
6550
+ # SEC 1/RFC 5915 ECPrivateKey format is required.
6551
+ #
6552
+ # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
6553
+ # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
6333
6554
  #
6334
6555
  alias to_pem export
6335
6556
 
@@ -6771,6 +6992,18 @@ module OpenSSL
6771
6992
  # Serializes the private key to PEM-encoded PKCS #8 format. See #private_to_der
6772
6993
  # for more details.
6773
6994
  #
6995
+ # An unencrypted PEM-encoded key will look like:
6996
+ #
6997
+ # -----BEGIN PRIVATE KEY-----
6998
+ # [...]
6999
+ # -----END PRIVATE KEY-----
7000
+ #
7001
+ # An encrypted PEM-encoded key will look like:
7002
+ #
7003
+ # -----BEGIN ENCRYPTED PRIVATE KEY-----
7004
+ # [...]
7005
+ # -----END ENCRYPTED PRIVATE KEY-----
7006
+ #
6774
7007
  def private_to_pem: (String cipher, String password) -> String
6775
7008
  | () -> String
6776
7009
 
@@ -6788,6 +7021,12 @@ module OpenSSL
6788
7021
  # -->
6789
7022
  # Serializes the public key to PEM-encoded X.509 SubjectPublicKeyInfo format.
6790
7023
  #
7024
+ # A PEM-encoded key will look like:
7025
+ #
7026
+ # -----BEGIN PUBLIC KEY-----
7027
+ # [...]
7028
+ # -----END PUBLIC KEY-----
7029
+ #
6791
7030
  def public_to_pem: () -> String
6792
7031
 
6793
7032
  # <!--
@@ -6909,13 +7148,58 @@ module OpenSSL
6909
7148
 
6910
7149
  # <!--
6911
7150
  # rdoc-file=ext/openssl/ossl_pkey_rsa.c
6912
- # - rsa.export([cipher, pass_phrase]) => PEM-format String
6913
- # - rsa.to_pem([cipher, pass_phrase]) => PEM-format String
6914
- # - rsa.to_s([cipher, pass_phrase]) => PEM-format String
7151
+ # - rsa.export([cipher, password]) => PEM-format String
7152
+ # - rsa.to_pem([cipher, password]) => PEM-format String
7153
+ # - rsa.to_s([cipher, password]) => PEM-format String
6915
7154
  # -->
6916
- # Outputs this keypair in PEM encoding. If *cipher* and *pass_phrase* are given
6917
- # they will be used to encrypt the key. *cipher* must be an OpenSSL::Cipher
6918
- # instance.
7155
+ # Serializes a private or public key to a PEM-encoding.
7156
+ #
7157
+ # When the key contains public components only
7158
+ # : Serializes it into an X.509 SubjectPublicKeyInfo. The parameters *cipher*
7159
+ # and *password* are ignored.
7160
+ #
7161
+ # A PEM-encoded key will look like:
7162
+ #
7163
+ # -----BEGIN PUBLIC KEY-----
7164
+ # [...]
7165
+ # -----END PUBLIC KEY-----
7166
+ #
7167
+ # Consider using #public_to_pem instead. This serializes the key into an
7168
+ # X.509 SubjectPublicKeyInfo regardless of whether the key is a public key
7169
+ # or a private key.
7170
+ #
7171
+ # When the key contains private components, and no parameters are given
7172
+ # : Serializes it into a PKCS #1 RSAPrivateKey.
7173
+ #
7174
+ # A PEM-encoded key will look like:
7175
+ #
7176
+ # -----BEGIN RSA PRIVATE KEY-----
7177
+ # [...]
7178
+ # -----END RSA PRIVATE KEY-----
7179
+ #
7180
+ # When the key contains private components, and *cipher* and *password* are given
7181
+ # : Serializes it into a PKCS #1 RSAPrivateKey and encrypts it in OpenSSL's
7182
+ # traditional PEM encryption format. *cipher* must be a cipher name
7183
+ # understood by OpenSSL::Cipher.new or an instance of OpenSSL::Cipher.
7184
+ #
7185
+ # An encrypted PEM-encoded key will look like:
7186
+ #
7187
+ # -----BEGIN RSA PRIVATE KEY-----
7188
+ # Proc-Type: 4,ENCRYPTED
7189
+ # DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
7190
+ #
7191
+ # [...]
7192
+ # -----END RSA PRIVATE KEY-----
7193
+ #
7194
+ # Note that this format uses MD5 to derive the encryption key, and hence
7195
+ # will not be available on FIPS-compliant systems.
7196
+ #
7197
+ #
7198
+ # **This method is kept for compatibility.** This should only be used when the
7199
+ # PKCS #1 RSAPrivateKey format is required.
7200
+ #
7201
+ # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
7202
+ # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
6919
7203
  #
6920
7204
  def export: (String cipher, String password) -> String
6921
7205
  | () -> String
@@ -7093,21 +7377,118 @@ module OpenSSL
7093
7377
  # rdoc-file=ext/openssl/ossl_pkey_rsa.c
7094
7378
  # - rsa.to_der => DER-format String
7095
7379
  # -->
7096
- # Outputs this keypair in DER encoding.
7380
+ # Serializes a private or public key to a DER-encoding.
7381
+ #
7382
+ # See #to_pem for details.
7383
+ #
7384
+ # **This method is kept for compatibility.** This should only be used when the
7385
+ # PKCS #1 RSAPrivateKey format is required.
7386
+ #
7387
+ # Consider using #public_to_der or #private_to_der instead.
7097
7388
  #
7098
7389
  def to_der: () -> String
7099
7390
 
7100
7391
  # <!-- rdoc-file=ext/openssl/ossl_pkey_rsa.c -->
7101
- # Outputs this keypair in PEM encoding. If *cipher* and *pass_phrase* are given
7102
- # they will be used to encrypt the key. *cipher* must be an OpenSSL::Cipher
7103
- # instance.
7392
+ # Serializes a private or public key to a PEM-encoding.
7393
+ #
7394
+ # When the key contains public components only
7395
+ # : Serializes it into an X.509 SubjectPublicKeyInfo. The parameters *cipher*
7396
+ # and *password* are ignored.
7397
+ #
7398
+ # A PEM-encoded key will look like:
7399
+ #
7400
+ # -----BEGIN PUBLIC KEY-----
7401
+ # [...]
7402
+ # -----END PUBLIC KEY-----
7403
+ #
7404
+ # Consider using #public_to_pem instead. This serializes the key into an
7405
+ # X.509 SubjectPublicKeyInfo regardless of whether the key is a public key
7406
+ # or a private key.
7407
+ #
7408
+ # When the key contains private components, and no parameters are given
7409
+ # : Serializes it into a PKCS #1 RSAPrivateKey.
7410
+ #
7411
+ # A PEM-encoded key will look like:
7412
+ #
7413
+ # -----BEGIN RSA PRIVATE KEY-----
7414
+ # [...]
7415
+ # -----END RSA PRIVATE KEY-----
7416
+ #
7417
+ # When the key contains private components, and *cipher* and *password* are given
7418
+ # : Serializes it into a PKCS #1 RSAPrivateKey and encrypts it in OpenSSL's
7419
+ # traditional PEM encryption format. *cipher* must be a cipher name
7420
+ # understood by OpenSSL::Cipher.new or an instance of OpenSSL::Cipher.
7421
+ #
7422
+ # An encrypted PEM-encoded key will look like:
7423
+ #
7424
+ # -----BEGIN RSA PRIVATE KEY-----
7425
+ # Proc-Type: 4,ENCRYPTED
7426
+ # DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
7427
+ #
7428
+ # [...]
7429
+ # -----END RSA PRIVATE KEY-----
7430
+ #
7431
+ # Note that this format uses MD5 to derive the encryption key, and hence
7432
+ # will not be available on FIPS-compliant systems.
7433
+ #
7434
+ #
7435
+ # **This method is kept for compatibility.** This should only be used when the
7436
+ # PKCS #1 RSAPrivateKey format is required.
7437
+ #
7438
+ # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
7439
+ # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
7104
7440
  #
7105
7441
  alias to_pem export
7106
7442
 
7107
7443
  # <!-- rdoc-file=ext/openssl/ossl_pkey_rsa.c -->
7108
- # Outputs this keypair in PEM encoding. If *cipher* and *pass_phrase* are given
7109
- # they will be used to encrypt the key. *cipher* must be an OpenSSL::Cipher
7110
- # instance.
7444
+ # Serializes a private or public key to a PEM-encoding.
7445
+ #
7446
+ # When the key contains public components only
7447
+ # : Serializes it into an X.509 SubjectPublicKeyInfo. The parameters *cipher*
7448
+ # and *password* are ignored.
7449
+ #
7450
+ # A PEM-encoded key will look like:
7451
+ #
7452
+ # -----BEGIN PUBLIC KEY-----
7453
+ # [...]
7454
+ # -----END PUBLIC KEY-----
7455
+ #
7456
+ # Consider using #public_to_pem instead. This serializes the key into an
7457
+ # X.509 SubjectPublicKeyInfo regardless of whether the key is a public key
7458
+ # or a private key.
7459
+ #
7460
+ # When the key contains private components, and no parameters are given
7461
+ # : Serializes it into a PKCS #1 RSAPrivateKey.
7462
+ #
7463
+ # A PEM-encoded key will look like:
7464
+ #
7465
+ # -----BEGIN RSA PRIVATE KEY-----
7466
+ # [...]
7467
+ # -----END RSA PRIVATE KEY-----
7468
+ #
7469
+ # When the key contains private components, and *cipher* and *password* are given
7470
+ # : Serializes it into a PKCS #1 RSAPrivateKey and encrypts it in OpenSSL's
7471
+ # traditional PEM encryption format. *cipher* must be a cipher name
7472
+ # understood by OpenSSL::Cipher.new or an instance of OpenSSL::Cipher.
7473
+ #
7474
+ # An encrypted PEM-encoded key will look like:
7475
+ #
7476
+ # -----BEGIN RSA PRIVATE KEY-----
7477
+ # Proc-Type: 4,ENCRYPTED
7478
+ # DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
7479
+ #
7480
+ # [...]
7481
+ # -----END RSA PRIVATE KEY-----
7482
+ #
7483
+ # Note that this format uses MD5 to derive the encryption key, and hence
7484
+ # will not be available on FIPS-compliant systems.
7485
+ #
7486
+ #
7487
+ # **This method is kept for compatibility.** This should only be used when the
7488
+ # PKCS #1 RSAPrivateKey format is required.
7489
+ #
7490
+ # Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
7491
+ # (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
7111
7492
  #
7112
7493
  alias to_s export
7113
7494
 
@@ -7153,8 +7534,8 @@ module OpenSSL
7153
7534
  # <!--
7154
7535
  # rdoc-file=ext/openssl/ossl_pkey_rsa.c
7155
7536
  # - RSA.new -> rsa
7156
- # - RSA.new(encoded_key [, passphrase]) -> rsa
7157
- # - RSA.new(encoded_key) { passphrase } -> rsa
7537
+ # - RSA.new(encoded_key [, password ]) -> rsa
7538
+ # - RSA.new(encoded_key) { password } -> rsa
7158
7539
  # - RSA.new(size [, exponent]) -> rsa
7159
7540
  # -->
7160
7541
  # Generates or loads an RSA keypair.
@@ -7164,9 +7545,9 @@ module OpenSSL
7164
7545
  # #set_crt_params.
7165
7546
  #
7166
7547
  # If called with a String, tries to parse as DER or PEM encoding of an RSA key.
7167
- # Note that, if *passphrase* is not specified but the key is encrypted with a
7168
- # passphrase, OpenSSL will prompt for it. See also OpenSSL::PKey.read which can
7169
- # parse keys of any kinds.
7548
+ # Note that if *password* is not specified, but the key is encrypted with a
7549
+ # password, OpenSSL will prompt for it. See also OpenSSL::PKey.read which can
7550
+ # parse keys of any kind.
7170
7551
  #
7171
7552
  # If called with a number, generates a new key pair. This form works as an alias
7172
7553
  # of RSA.generate.
@@ -7174,7 +7555,7 @@ module OpenSSL
7174
7555
  # Examples:
7175
7556
  # OpenSSL::PKey::RSA.new 2048
7176
7557
  # OpenSSL::PKey::RSA.new File.read 'rsa.pem'
7177
- # OpenSSL::PKey::RSA.new File.read('rsa.pem'), 'my pass phrase'
7558
+ # OpenSSL::PKey::RSA.new File.read('rsa.pem'), 'my password'
7178
7559
  #
7179
7560
  def initialize: () -> void
7180
7561
  | (Integer key_size) -> void