2016-04-22 19:21:51 +08:00
|
|
|
#! /usr/bin/env perl
|
2023-09-07 16:59:15 +08:00
|
|
|
# Copyright 2015-2023 The OpenSSL Project Authors. All Rights Reserved.
|
2016-04-22 19:21:51 +08:00
|
|
|
#
|
2018-12-06 20:05:25 +08:00
|
|
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-04-22 19:21:51 +08:00
|
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
|
|
# in the file LICENSE in the source distribution or at
|
|
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
2015-04-18 02:13:58 +08:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use File::Spec;
|
2016-01-30 08:05:33 +08:00
|
|
|
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
2015-09-20 05:19:14 +08:00
|
|
|
use OpenSSL::Test::Utils;
|
2015-04-18 02:13:58 +08:00
|
|
|
|
|
|
|
setup("test_rsa");
|
|
|
|
|
2022-11-15 10:38:31 +08:00
|
|
|
plan tests => 14;
|
2020-02-12 13:03:51 +08:00
|
|
|
|
|
|
|
require_ok(srctop_file('test', 'recipes', 'tconversion.pl'));
|
2015-04-18 02:13:58 +08:00
|
|
|
|
|
|
|
ok(run(test(["rsa_test"])), "running rsatest");
|
|
|
|
|
2020-02-12 13:03:51 +08:00
|
|
|
run_rsa_tests("pkey");
|
2016-08-22 23:25:12 +08:00
|
|
|
|
2020-03-03 09:03:47 +08:00
|
|
|
run_rsa_tests("rsa");
|
2017-01-04 16:34:42 +08:00
|
|
|
|
2020-02-12 13:03:51 +08:00
|
|
|
sub run_rsa_tests {
|
|
|
|
my $cmd = shift;
|
|
|
|
|
|
|
|
ok(run(app([ 'openssl', $cmd, '-check', '-in', srctop_file('test', 'testrsa.pem'), '-noout'])),
|
|
|
|
"$cmd -check" );
|
|
|
|
|
2022-11-15 10:38:31 +08:00
|
|
|
SKIP: {
|
|
|
|
skip "Skipping Deprecated rsa_x931_test", 1 if disabled("deprecated-3.0");
|
|
|
|
ok(run(test(['rsa_x931_test'])), "RSA X931 test");
|
|
|
|
};
|
|
|
|
|
2021-12-03 05:08:25 +08:00
|
|
|
SKIP: {
|
2020-02-12 13:03:51 +08:00
|
|
|
skip "Skipping $cmd conversion test", 3
|
2021-06-18 15:46:40 +08:00
|
|
|
if disabled("rsa");
|
2020-02-12 13:03:51 +08:00
|
|
|
|
|
|
|
subtest "$cmd conversions -- private key" => sub {
|
2021-06-18 15:46:40 +08:00
|
|
|
tconversion( -type => $cmd, -prefix => "$cmd-priv",
|
2020-10-15 22:53:29 +08:00
|
|
|
-in => srctop_file("test", "testrsa.pem") );
|
2020-02-12 13:03:51 +08:00
|
|
|
};
|
|
|
|
subtest "$cmd conversions -- private key PKCS#8" => sub {
|
2021-06-18 15:46:40 +08:00
|
|
|
tconversion( -type => $cmd, -prefix => "$cmd-pkcs8",
|
2020-10-15 22:53:29 +08:00
|
|
|
-in => srctop_file("test", "testrsa.pem"),
|
|
|
|
-args => ["pkey"] );
|
2020-02-12 13:03:51 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-12-03 05:08:25 +08:00
|
|
|
SKIP: {
|
2020-02-12 13:03:51 +08:00
|
|
|
skip "Skipping msblob conversion test", 1
|
2021-06-18 15:46:40 +08:00
|
|
|
if disabled($cmd) || $cmd eq 'pkey';
|
2020-02-12 13:03:51 +08:00
|
|
|
|
|
|
|
subtest "$cmd conversions -- public key" => sub {
|
2021-06-18 15:46:40 +08:00
|
|
|
tconversion( -type => 'msb', -prefix => "$cmd-msb-pub",
|
2020-10-15 22:53:29 +08:00
|
|
|
-in => srctop_file("test", "testrsapub.pem"),
|
|
|
|
-args => ["rsa", "-pubin", "-pubout"] );
|
2020-02-12 13:03:51 +08:00
|
|
|
};
|
|
|
|
}
|
2021-12-03 05:08:25 +08:00
|
|
|
SKIP: {
|
|
|
|
skip "Skipping PVK conversion test", 1
|
|
|
|
if disabled($cmd) || $cmd eq 'pkey' || disabled("rc4")
|
|
|
|
|| disabled ("legacy");
|
|
|
|
|
|
|
|
subtest "$cmd conversions -- private key" => sub {
|
|
|
|
tconversion( -type => 'pvk', -prefix => "$cmd-pvk",
|
|
|
|
-in => srctop_file("test", "testrsa.pem"),
|
|
|
|
-args => ["rsa", "-passin", "pass:testpass",
|
|
|
|
"-passout", "pass:testpass",
|
|
|
|
"-provider", "default",
|
|
|
|
"-provider", "legacy"] );
|
|
|
|
};
|
|
|
|
}
|
2015-04-18 02:13:58 +08:00
|
|
|
}
|