|
5 | 5 |
|
6 | 6 | class OpenSSL::TestEC < OpenSSL::PKeyTestCase
|
7 | 7 | def test_ec_key
|
8 |
| - builtin_curves = OpenSSL::PKey::EC.builtin_curves |
9 |
| - assert_not_empty builtin_curves |
10 |
| - |
11 |
| - builtin_curves.each do |curve_name, comment| |
12 |
| - # Oakley curves and X25519 are not suitable for signing and causes |
13 |
| - # FIPS-selftest failure on some environment, so skip for now. |
14 |
| - next if ["Oakley", "X25519"].any? { |n| curve_name.start_with?(n) } |
15 |
| - |
16 |
| - key = OpenSSL::PKey::EC.generate(curve_name) |
17 |
| - assert_predicate key, :private? |
18 |
| - assert_predicate key, :public? |
19 |
| - assert_nothing_raised { key.check_key } |
20 |
| - end |
21 |
| - |
22 | 8 | key1 = OpenSSL::PKey::EC.generate("prime256v1")
|
23 | 9 |
|
24 | 10 | # PKey is immutable in OpenSSL >= 3.0; constructing an empty EC object is
|
@@ -49,6 +35,17 @@ def test_ec_key
|
49 | 35 | end
|
50 | 36 | end
|
51 | 37 |
|
| 38 | + def test_builtin_curves |
| 39 | + builtin_curves = OpenSSL::PKey::EC.builtin_curves |
| 40 | + assert_not_empty builtin_curves |
| 41 | + assert_equal 2, builtin_curves[0].size |
| 42 | + assert_kind_of String, builtin_curves[0][0] |
| 43 | + assert_kind_of String, builtin_curves[0][1] |
| 44 | + |
| 45 | + builtin_curve_names = builtin_curves.map { |name, comment| name } |
| 46 | + assert_include builtin_curve_names, "prime256v1" |
| 47 | + end |
| 48 | + |
52 | 49 | def test_generate
|
53 | 50 | assert_raise(OpenSSL::PKey::ECError) { OpenSSL::PKey::EC.generate("non-existent") }
|
54 | 51 | g = OpenSSL::PKey::EC::Group.new("prime256v1")
|
|
0 commit comments