Replace `tool/update-deps` with a Ruby source scanner so dependency
updates no longer require GNU make, a configured build, or compiler
preprocessor output.
Keep compact source mappings and scanner declarations in dependency
files, and expand complete rules into the build directory. Avoid the
temporary fixture headers required by the compiler-driven prototype.
Use the generated rules from GNU make, BSD make, and NMake builds.
Support out-of-tree and read-only source trees, and retain expanded
dependencies shipped in release archives when baseruby is unavailable.
OpenSSL 3.0 changed the type of SSL options to uint64_t. Since OpenSSL
3.2 began using the 33rd bit, treating it as unsigned long is no longer
sufficient.
https://github.com/ruby/openssl/commit/743daa7ac9
Allocate the underlying OpenSSL object in #initialize{,_copy} instead
of .allocate. Allocating an empty OpenSSL object in .allocate is
wasteful because #initialize{,_copy} cannot always reuse an existing
object and have to allocate a new one.
Some ruby/openssl classes already follow this approach, such as
OpenSSL::PKey::PKey. Let's standardize on it.
Also expand New*() and Set*() macros, which are only used once or twice
and are not very helpful for readability in my opinion.
https://github.com/ruby/openssl/commit/5f10428793
Simplify the code and raise exceptions with a consistent error message.
This unifies the exception type raised when #initialize is called twice
to TypeError. This should not affect valid usage of these classes.
https://github.com/ruby/openssl/commit/24f72a8350
Allocate the wrapper object before attempting to load the provider.
Also, expand macros NewProvider() and SetProvider(), which are only
used once and are unlikely to be reused in the future.
https://github.com/ruby/openssl/commit/f62cc13cfa
We can implement this now that we require Ruby 2.7 or later.
The return value of OpenSSL's *_set_ex_data() functions is not checked
since replacing an existing index should not fail.
https://github.com/ruby/openssl/commit/98acd95e86
OpenSSL::X509::Store{,Context}#flags= does not clear existing flags.
Instead, it ORs new flags to the current set. This is contrary to
normal convention and likely unintentional, but changing the behavior
would not be acceptable for compatibility reasons.
Add #flags to get the current flags to allow users to explicitly express
the intention with "store.flags |= OpenSSL::X509::V_...".
Also, add #clear_flags to remove existing flags. The underlying OpenSSL
C APIs appear to have been added in a patch release of OpenSSL 0.9.8.
Warn in #flags= if the argument is not a superset of the existing flags.
https://github.com/ruby/openssl/commit/a245620e2e
OSSL_3_const was useful when supporting OpenSSL 1.0.2-3.x at the same
time. Since support for OpenSSL < 1.1.1 has been dropped, most uses can
simply be replaced with plain const.
https://github.com/ruby/openssl/commit/ce050d7740
"~> 0.14" is equivalent to ">= 0.14, < 1". Since the openssl gem is an
empty stub on JRuby, there is no good reason to specify version bounds
on jruby-openssl.
[ky: commit message]
https://github.com/ruby/openssl/commit/3ffbe73aaa
Co-authored-by: Kazuki Yamaguchi <k@rhe.jp>
Feeding a deeply nested constructed encoding to OpenSSL::ASN1.decode,
.decode_all, or .traverse can cause unbounded recursion and result in
SystemStackError.
Add an explicit nesting depth limit of 200 levels and raise
OpenSSL::ASN1::ASN1Error if it is exceeded. This limit is arbitrary and
currently not configurable, but should be sufficient for any practical
use cases.
Fixes https://hackerone.com/reports/3662125https://github.com/ruby/openssl/commit/fc753239cc
OpenSSL::KDF.pbkdf2_hmac and .scrypt are currently not interrupted by
Timeout.timeout because they make a single, slow OpenSSL function call
during which Ruby-level interrupts cannot be handled. Add advice against
using parameters from untrusted inputs.
https://github.com/ruby/openssl/commit/58c0b81a59
Use class_eval with a string so the initialize instance method, and the
digest and hexdigest class methods are not defined via define_method
with a Proc (which is not Ractor-safe).
https://github.com/ruby/openssl/commit/502bc6c378
The variable-sized alloca makes me nervous, even though it turned out
to be safe: the Finished message is 36 bytes long in SSL 3.0 and is
usually smaller in newer protocol versions. However, the alloca is not
actually needed since we can simply write into the String's content.
While at it, update the rdoc comment to clarify the difference of the
two methods.
https://github.com/ruby/openssl/commit/2e74589683
The return value behaviour isn't explicitly documented for OpenSSL.
For LibreSSL, it says [1]:
> EVP_CIPHER_CTX_ctrl() returns 1 for success or 0 for failure.
> Some implementations may return negative values for some errors.
So it appears that we need to check for `<= 0` instead of `!0`.
Furthermore, I looked for how OpenSSL does this and found it also does
things inconsistently. I submitted a PR to check for `<= 0` which was
accepted [2].
[1] https://man.openbsd.org/EVP_CIPHER_CTX_ctrl.3
[2] https://github.com/openssl/openssl/pull/30923https://github.com/ruby/openssl/commit/811f2ca57e
Embarrassingly, the previous commits introduced OPENSSL_cleanse() calls
against the temporary struct instead of the buffer content. Thanks to
nagachika for noticing.
https://github.com/ruby/openssl/commit/8eca3efad4
Since PBKDF2 runs single-threaded and is typically configured to take
several hundred milliseconds or longer, it is a perfect candidate to be
run without the GVL.
https://github.com/ruby/openssl/commit/2a24966414
ASN1_STRING has been made opaque in OpenSSL's master branch. Use the
new accessor functions instead of accessing fields directly.
Other uses of ASN1_STRING fields were already updated in
<https://github.com/ruby/openssl/pull/978>. This patch converts the
remaining ones, which require the new functions added in OpenSSL 4.0
and were not available at that time.
https://github.com/ruby/openssl/commit/ebb505f217
OpenSSL's master branch is changing functions to return const pointers
where the returned objects are not meant to be modified by the caller.
Update ossl_*_new() to take const pointers accordingly. Unfortunately,
*_dup() in older versions of OpenSSL and in LibreSSL/AWS-LC take
non-const pointers, so const casts are required.
https://github.com/ruby/openssl/commit/34c49e6c6c