Commit graph

9 commits

Author SHA1 Message Date
Kazuki Yamaguchi
d4621b42f2 [ruby/openssl] test/openssl/test_ossl.rb: fix style issues
Use OpenSSL::TestCase instead of OpenSSL::SSLTestCase.

Prefer assert_true and assert_false over the bare assert and refute.
OpenSSL.fixed_length_secure_compare and OpenSSL.secure_compare will
only return true or false, and it should be checked.

3d9938ed40
2025-07-21 14:31:24 +00:00
Kazuki Yamaguchi
090825f5fc [ruby/openssl] Move slow tests to OSSL_TEST_ALL=1 only
Update GitHub Actions workflows to set OSSL_TEST_ALL=1.

Exclude a few slow tests that are not critical for local development,
unless OSSL_TEST_ALL=1 is set. The bindings code paths are still reached
by other tests with smaller inputs, and failures in those would likely
indicate an issue in OpenSSL rather than in the bindings.

Newly excluded tests include generating large DSA keys and measuring
CRYPTO_memcmp() timing. These tests currently take nearly half of the
total runtime.

382eca2aec
2025-07-21 14:31:24 +00:00
Kazuki Yamaguchi
81c83fd79f [ruby/openssl] test/openssl/test_ossl.rb: use clock_gettime for measuring time
The benchmark library is planned to become a bundled gem in Ruby 3.5.
While we can add it in our Gemfile, it is only used in
test_memcmp_timing and the usage can be easily replaced with a few
Process.clock_gettime calls.

9a746ed1a4
2025-01-29 17:14:40 +00:00
Hiroshi SHIBATA
1515353353 Make optional benchmark test in OpenSSL::OSSL#test_memcmp_timing 2024-08-29 17:37:44 +09:00
Kazuki Yamaguchi
1d4a43e7b0 [ruby/openssl] test/openssl/test_ossl.rb: relax assertion for error messages
The test case test_error_data utilizes the error message generated by
X509V3_EXT_nconf_nid(). The next commit will use X509V3_EXT_nconf(),
which generates a slightly different error message. Let's adapt the
check to it.

9cdfa3a4d1
2023-09-06 19:30:55 +09:00
Kazuki Yamaguchi
12bdacdca5 [ruby/openssl] Include "additional data" message in OpenSSL errors
Error entries in the OpenSSL error queue may contain additional
contextual information associated with the error, which can be helpful
when debugging.

This "additional data" is currently only printed to stderr when
OpenSSL.debug is enabled. Let's include this in the exception messages
raised with ossl_raise(), too.

	$ ruby -Ilib -ropenssl -e'OpenSSL.debug=true; OpenSSL::SSL::SSLContext.new.ecdh_curves="P-256:not-a-curve"'
	-e:1: warning: error on stack: error:0A080106:SSL routines:gid_cb:passed invalid argument (group 'not-a-curve' cannot be set)
	-e:1:in `ecdh_curves=': passed invalid argument (group 'not-a-curve' cannot be set) (OpenSSL::SSL::SSLError)
		from -e:1:in `<main>'

1c5bbdd68e
2023-08-16 14:48:41 +09:00
Bart de Water
0b2c70eaa1 [ruby/openssl] Look up digest by name instead of constant
b28fb2f05c
2020-05-13 15:47:51 +09:00
Yusuke Endoh
01138f5853 Make OpenSSL::OSSL#test_memcmp_timing robust
The test was too fragile.  Actually, it fails on one of our CIs
immediately after it was merged to ruby/ruby.

https://gist.github.com/ko1/7ea4a5826641f79e2f9e041d83e45dba#file-brlog-trunk_clang_40-20200216-101730-L532-L535
https://gist.github.com/ko1/1c657746092b871359d8bf9e0ad28921#file-brlog-trunk-test4-20200216-104518-L473-L476

* Two measurements, a-b and a-c, must be interative instead of
  sequential; the execution time will be easily affected by disturbance
  (say, cron job or some external process invoked during measurement)

* The comparison of the two results must be relative instead of
  absolute; slow machine may take several tens of seconds for each
  execution, and one delta second is too small.  The test cases of a, b,
  and c are very extreme, so if the target method has a bug, the two
  execution times would be very different.  So I think it is enough to
  check if the difference is less than 10 times.

This change is the same as https://github.com/ruby/openssl/pull/332
2020-02-16 19:55:19 +09:00
Hiroshi SHIBATA
b99775b163
Import openssl-2.2.0 (#2693)
Import the master branch of ruby/openssl for preparing to release openssl-2.2.0
2020-02-16 15:21:29 +09:00