Commit graph

8776 commits

Author SHA1 Message Date
Kazuki Yamaguchi
498c8e8f17 [ruby/openssl] pkey: assume generic PKeys contain private components
The EVP interface cannot tell whether if a pkey contains the private
components or not. Assume it does if it does not respond to #private?.
This fixes the NoMethodError on calling #sign on a generic PKey.

f4c717bcb2
2021-03-16 19:16:11 +09:00
Kazuki Yamaguchi
1f44640677 [ruby/openssl] pkey: refactor #export/#to_pem and #to_der
Add ossl_pkey_export_traditional() and ossl_pkey_export_spki() helper
functions, and use them. This reduces code duplication.

56f0d34d63
2021-03-16 19:16:10 +09:00
Kazuki Yamaguchi
707e3d49cb [ruby/openssl] pkey: refactor DER/PEM-encoded string parsing code
Export the flow used by OpenSSL::PKey.read and let the subclasses call
it before attempting other formats.

d963d4e276
2021-03-16 19:16:10 +09:00
Kazuki Yamaguchi
10d360847b [ruby/openssl] pkey: prefer PKey.read over PKey::RSA.new in docs
cf92a3ffba
2021-03-16 19:16:10 +09:00
Kazuki Yamaguchi
efad0166c6 [ruby/openssl] pkey: have PKey.read parse PEM-encoded DHParameter
Try PEM_read_bio_Parameters(). Only PEM format is supported at the
moment since corresponding d2i_* functions are not provided by OpenSSL.

867e5c021b
2021-03-16 19:16:10 +09:00
Kazuki Yamaguchi
c157f6e787 [ruby/openssl] pkey: inline {rsa,dsa,dh,ec}_instance()
Merge the code into the callers so that the wrapping Ruby object is
allocated before the raw key object is allocated. This prevents possible
memory leak on Ruby object allocation failure, and also reduces the
lines of code.

1eb1366615
2021-03-16 19:16:10 +09:00
Kazuki Yamaguchi
27859c09a6 [ruby/openssl] pkey: simplify ossl_pkey_new()
ossl_{rsa,dsa,dh,ec}_new() called from this function are not used
anywhere else. Inline them into pkey_new0() and reduce code
duplication.

94aeab2f26
2021-03-16 19:16:10 +09:00
Kazuki Yamaguchi
10289e9f22 [ruby/openssl] config: replace DupConfigPtr() with GetConfig()
Now that OpenSSL::Config wraps a real CONF object, the caller can just
borrow it rather than creating a new temporary CONF object. CONF object
is usually treated as immutable.

DupConfigPtr() is now removed, and GetConfig() is exported instead.

d9064190ca
2021-03-16 19:16:10 +09:00
Kazuki Yamaguchi
22aeb6373e [ruby/openssl] config: revert to C implementation of OpenSSL::Config
Revert OpenSSL::Config to using the OpenSSL API and remove our own
parser implementation for the config file syntax.

OpenSSL::Config now wraps a CONF object. Accessor methods deal with the
object directly rather than Ruby-level internal state.

This work is based on the old C code we used before 2010.

c891e0ea89
2021-03-16 19:16:10 +09:00
Kazuki Yamaguchi
67f5847c61 [ruby/openssl] config: remove deprecated methods
Remove 4 deprecated methods.

The following two methods have been marked as deprecated since 2003,
by r4531 (ruby.git commit 78ff3833fb).

 - OpenSSL::Config#value
 - OpenSSL::Config#section

Other two methods are removed because the corresponding functions
disappeared in OpenSSL 1.1.0.

 - OpenSSL::Config#add_value
 - OpenSSL::Config#[]=

9783d7f21c
2021-03-16 19:16:10 +09:00
Spencer McIntyre
4d8bce227c [ruby/openssl] Define Cipher #ccm_data_len= for CCM mode ciphers
Allow specifying just length to #update

CCM mode ciphers need to specify the total plaintext or ciphertext
length to EVP_CipherUpdate.

Update the link to the tests file

Define Cipher#ccm_data_len= for CCM mode ciphers

Add a unit test for CCM mode

Also check CCM is authenticated when testing

bb3816953b
2021-03-16 19:16:10 +09:00
wanabe
0c5f8c6276 [ruby/zlib] Resume zstream if available [Bug #10961] 2021-03-09 13:19:03 +09:00
Nobuyoshi Nakada
32a13591e0
[ruby/stringio] Check if closed in loop
[Bug #17675] https://bugs.ruby-lang.org/issues/17675

1ed61d0cbc
2021-03-08 10:13:29 +09:00
Hiroshi SHIBATA
99f54c0895
[ruby/stringio] Use Gemfile instead of Gem::Specification#add_development_dependency.
157fe9f04d
2021-03-08 10:12:57 +09:00
Nobuyoshi Nakada
f6d5de8f33 [ruby/io-wait] Declare as Ractor-safe
Fixes https://bugs.ruby-lang.org/issues/17659

ba338b4764
2021-03-07 09:54:35 +09:00
Nobuyoshi Nakada
ea81fff564 [ruby/io-wait] bump up to 0.1.1
88db082d60
2021-03-07 09:54:35 +09:00
Nobuyoshi Nakada
05d118feea [ruby/io-wait] Fixed required_ruby_version
Before 3.0.0, io-wait has not been gemified.

6fed3da323
2021-03-07 09:54:35 +09:00
Nobuyoshi Nakada
3ba1580d80 [ruby/io-wait] Revise IO#wait arguments
0599f6d4d6
4e982aea1b
5b45685eb3
2021-03-07 09:54:35 +09:00
Aaron Patterson
d45466dc5b
Oops! Add another test and fix to_proc implementation 2021-02-26 10:06:56 -08:00
Aaron Patterson
0590e9b677
Fiddle::Function responds to to_proc
This lets us cast a Fiddle::Function to a block, allowing is to write
things like:

```ruby
f = Fiddle::Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
define_method :strcpy, &f
```
2021-02-26 09:57:13 -08:00
Shugo Maeda
5de38c41ae
ripper: fix a bug of Ripper::Lexer with syntax error and heredoc [Bug #17644] 2021-02-19 16:40:29 +09:00
Nobuyoshi Nakada
9a5da2dcff [ruby/readline-ext] Initialize libedit before managing the history
Fixes https://bugs.ruby-lang.org/issues/17629

250d6787ed
2021-02-18 21:18:37 +09:00
Jeremy Evans
c03b723f56 Update class documentation for StringScanner
The [] wasn't being displayed, and try to fix formatting for bol?
and << (even if they aren't linked).

Fixes [Bug #17620]
2021-02-10 08:17:07 -08:00
Hiroshi SHIBATA
e72757a311 [ruby/zlib] Don't use gemspec for gem dependecy
7d3d19710f
2021-02-10 12:49:33 +09:00
Nobuyoshi Nakada
6bb103f012
[ruby/console] Updated depend 2021-02-09 17:49:28 +09:00
Nobuyoshi Nakada
5bfca88f76
[ruby/io-console] Fixed typo 2021-02-09 17:39:00 +09:00
Nobuyoshi Nakada
df4f8aa248
[ruby/io-console] Fixed regression against 3.0 2021-02-09 17:38:52 +09:00
Samuel Williams
5f69a7f604
Expose scheduler as public interface & bug fixes. (#3945)
* Rename `rb_scheduler` to `rb_fiber_scheduler`.

* Use public interface if available.

* Use `rb_check_funcall` where possible.

* Don't use `unblock` unless the fiber was non-blocking.
2021-02-09 19:39:56 +13:00
Nobuyoshi Nakada
4186cd6435
Revert a part of "[DOC] refined" [ci skip]
This reverts commit 478716f49a
partially -- "Removed unnecessary parentheses" part -- because of
a lambda, see 9e25eb308d.
2021-02-08 21:46:07 +09:00
Nobuyoshi Nakada
478716f49a
[DOC] refined
* Adjusted indentation in license section, and used "(c)"
* Commented out invalid syntax to enable highlighting
* Removed unnecessary parentheses
2021-02-07 21:24:44 +09:00
Jean Boussier
3a888398a6 objspace_dump.c: tag singleton classes and reference the superclass 2021-02-04 09:53:31 -08:00
Dimitris Zorbas
46b5b51cc6 [DOC] Fix typo in ext/socket/socket.c [ci skip] 2021-02-04 13:29:58 +09:00
Kenta Murata
4e2e1d6093
[ruby/bigdecimal] Fix uint64 conversion
Stop using logarithm to compute the number of components.
Instead, use the theoretical maximum number of components for buffer,
and count up the actual number of components during conversion.

9067b353ac
2021-02-04 13:18:58 +09:00
Kenta Murata
868d66e0b5
[ruby/bigdecimal] Stop using rmpd and RMPD prefixes and DBLE_FIG
7479923fdb
2021-02-04 13:18:52 +09:00
Kenta Murata
8df1881c8f [ruby/bigdecimal] Fix the maximum length of float number
This change is for preventing the false-positive alert by CoverityScan.
See CID-1471770 for the detail.

4d5b97125b
2021-02-03 18:25:03 +09:00
Aaron Patterson
8ef30bcc04
Fix GC compatibility: Don't stash encodings in global constants
This value should either be pinned, or looked up when needed at runtime.
Without pinning, the GC may move the encoding object, and that could
cause a crash.

In this case it is easier to find the value at runtime, and there is no
performance penalty (as Ruby caches encoding indexes).  We can shorten
the code, be compaction friendly, and incur no performance penalty.
2021-02-01 12:20:34 -08:00
Nobuyoshi Nakada
9241211538 Forward keyword arguments for Pathname#each_line [Bug #17589] 2021-01-29 14:27:53 +09:00
Kenta Murata
a1bb110b56 [ruby/bigdecimal] [Doc] Fix the comment of BigDecimal_div2 [ci skip]
a109d0984f
2021-01-22 14:07:32 +09:00
Kenta Murata
887a1bfbbc [ruby/bigdecimal] Stop using GetVpValue in rb_big_convert_to_BigDecimal
034fd2b25e
2021-01-22 13:59:04 +09:00
Jean Boussier
6ca3d1af33 objspace_dump.c: Handle allocation path and line missing 2021-01-20 10:48:13 -08:00
manga_osyo
b84b253a69 Fix Ripper with heredoc. 2021-01-17 12:58:13 +09:00
Nobuyoshi Nakada
35a047301b
[ruby/io-console] Rubygems 3.2 supports --platform option
c8046fde84
2021-01-16 19:42:53 +09:00
Nobuyoshi Nakada
6ab5504fe5
[ruby/io-console] Moved JRuby version files into particular path
b0691d2c20
2021-01-16 19:42:52 +09:00
Nobuyoshi Nakada
92da224d22
[ruby/io-console] Delegate to JRuby version
Add `--platform` option tentatively.

3bf1a7b753
2021-01-16 19:42:52 +09:00
Nobuyoshi Nakada
c143a2f947
[ruby/io-console] bump up to 0.5.7
f55d7ebff6
2021-01-16 19:42:52 +09:00
Kenta Murata
b130644584 [ruby/bigdecimal] Fix for the coerce cases in divide and DoDivmod
1cb92487f7
2021-01-16 00:09:26 +09:00
Kenta Murata
9d0c5e2754 [ruby/bigdecimal] Use pre-allocated special values in BigDecimal_DoDivmod
d2746121cf
2021-01-16 00:08:09 +09:00
Kenta Murata
f95f85b215 [ruby/bigdecimal] Use new conversion functions in BigDecimal_DoDivmod
68c20200d5
2021-01-16 00:07:48 +09:00
Kenta Murata
0a039c5fbb [ruby/bigdecimal] Use new conversion functions in BigDecimal_divide
3b55ad1c42
2021-01-15 06:42:48 +09:00
Kenta Murata
500fc63cd0 [ruby/bigdecimal] Reorder the arguments of BigDecimal_divide
1e03da7076
2021-01-15 06:42:38 +09:00