Skip to content

Commit d974eda

Browse files
committed
Merge branch 'maint-3.2' into maint-3.3
* maint-3.2: pkey: avoid calling i2d_PUBKEY family on an incomplete key Cleanup Gemfile test/openssl/test_ossl.rb: use clock_gettime for measuring time Backport changes related to extracted stdlibs in Ruby 3.4-3.5
2 parents a0bf65f + e0ff759 commit d974eda

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

Gemfile

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
source "https://rubygems.org"
22

3-
group :development do
4-
gem "rake"
5-
gem "rake-compiler"
6-
gem "test-unit", "~> 3.0", ">= 3.4.6"
7-
gem "test-unit-ruby-core"
8-
gem "prime"
9-
# In the case of Ruby whose rdoc is not a default gem.
10-
gem "rdoc"
11-
end
3+
gem "rake"
4+
gem "rake-compiler"
5+
gem "test-unit", "~> 3.0", ">= 3.4.6"
6+
gem "test-unit-ruby-core"
7+
gem "prime"
8+
gem "rdoc"

ext/openssl/ossl_pkey.c

+1
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@ ossl_pkey_export_spki(VALUE self, int to_der)
937937
BIO *bio;
938938

939939
GetPKey(self, pkey);
940+
ossl_pkey_check_public_key(pkey);
940941
bio = BIO_new(BIO_s_mem());
941942
if (!bio)
942943
ossl_raise(ePKeyError, "BIO_new");

test/openssl/test_ossl.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ def test_memcmp_timing
5858

5959
a_b_time = a_c_time = 0
6060
100.times do
61-
a_b_time += Benchmark.measure { 100.times { OpenSSL.fixed_length_secure_compare(a, b) } }.real
62-
a_c_time += Benchmark.measure { 100.times { OpenSSL.fixed_length_secure_compare(a, c) } }.real
61+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
62+
100.times { OpenSSL.fixed_length_secure_compare(a, b) }
63+
t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
64+
100.times { OpenSSL.fixed_length_secure_compare(a, c) }
65+
t3 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
66+
67+
a_b_time += t2 - t1
68+
a_c_time += t3 - t2
6369
end
6470
assert_operator(a_b_time, :<, a_c_time * 10, "fixed_length_secure_compare timing test failed")
6571
assert_operator(a_c_time, :<, a_b_time * 10, "fixed_length_secure_compare timing test failed")

test/openssl/test_pkey_dsa.rb

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ def test_new_break
3333
end
3434
end
3535

36+
def test_new_empty
37+
key = OpenSSL::PKey::DSA.new
38+
assert_nil(key.p)
39+
assert_raise(OpenSSL::PKey::PKeyError) { key.to_der }
40+
end
41+
3642
def test_generate
3743
# DSA.generate used to call DSA_generate_parameters_ex(), which adjusts the
3844
# size of q according to the size of p

0 commit comments

Comments
 (0)