Skip to content

Commit 7d47798

Browse files
Merge pull request os-autoinst#22295 from paolostivanin/p183461
Refactor oqs-provider test
2 parents c38e442 + 8902892 commit 7d47798

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

tests/security/oqs_provider_openssl.pm

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,40 @@ sub run {
1919
if (zypper_call("--no-refresh if oqs-provider") != 0) {
2020
record_info('SKIPPING TEST', "Skipping test due to missing oqs-provider package.");
2121
} else {
22-
zypper_call("in gcc wget cmake oqs-provider liboqs-devel libopenssl-3-devel");
22+
zypper_call("in gcc wget cmake openssl oqs-provider");
2323

24-
my $oqs_version = "0.7.0";
25-
assert_script_run("wget --quiet " . data_url("security/oqs-provider-$oqs_version.tar.gz"));
26-
assert_script_run("tar xf oqs-provider-$oqs_version.tar.gz && cd oqs-provider-$oqs_version");
27-
assert_script_run("cmake -S . -B _build && cmake --build _build");
28-
assert_script_run("cd _build && export OPENSSL_CONF=/dev/null ; ctest --parallel 5 --rerun-failed --output-on-failure -V", 300);
24+
my $conf_file = '/etc/ssl/oqs-openssl.cnf';
25+
my $conf = <<EOF;
26+
openssl_conf = openssl_init
27+
28+
[openssl_init]
29+
providers = provider_sect
30+
31+
[provider_sect]
32+
default = default_sect
33+
oqs = oqs_sect
34+
35+
[default_sect]
36+
activate = 1
37+
38+
[oqs_sect]
39+
module = /usr/lib64/ossl-modules/oqsprovider.so
40+
EOF
41+
42+
script_output("echo '$conf' >> $conf_file");
43+
assert_script_run("export OPENSSL_CONF=$conf_file");
44+
assert_script_run("openssl list -provider oqs -public-key-algorithms | grep -q dilithium2");
45+
46+
my $key_path = "/root/dilithium2-key.pem";
47+
assert_script_run("openssl genpkey -provider oqs -algorithm dilithium2 -out $key_path");
48+
# Sign a message with the generated key
49+
my $test_file = "/tmp/input.txt";
50+
my $sig_file = "/tmp/input.sig";
51+
assert_script_run("echo 'openQA test' > $test_file");
52+
assert_script_run("openssl pkeyutl -sign -provider oqs -inkey $key_path -out $sig_file -in $test_file");
53+
54+
# Verify the signature using the same key
55+
assert_script_run("openssl pkeyutl -verify -provider oqs -inkey $key_path -sigfile $sig_file -in $test_file");
2956
}
3057
}
3158

0 commit comments

Comments
 (0)