2016-04-22 19:21:51 +08:00
|
|
|
#! /usr/bin/env perl
|
2020-04-23 20:55:52 +08:00
|
|
|
# Copyright 2015-2020 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");
|
|
|
|
|
2020-02-12 13:03:51 +08:00
|
|
|
plan tests => 10;
|
|
|
|
|
|
|
|
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" );
|
|
|
|
|
|
|
|
SKIP: {
|
|
|
|
skip "Skipping $cmd conversion test", 3
|
|
|
|
if disabled("rsa");
|
|
|
|
|
|
|
|
subtest "$cmd conversions -- private key" => sub {
|
2020-10-15 22:53:29 +08:00
|
|
|
tconversion( -type => $cmd, -prefix => "$cmd-priv",
|
|
|
|
-in => srctop_file("test", "testrsa.pem") );
|
2020-02-12 13:03:51 +08:00
|
|
|
};
|
|
|
|
subtest "$cmd conversions -- private key PKCS#8" => sub {
|
2020-10-15 22:53:29 +08:00
|
|
|
tconversion( -type => $cmd, -prefix => "$cmd-pkcs8",
|
|
|
|
-in => srctop_file("test", "testrsa.pem"),
|
|
|
|
-args => ["pkey"] );
|
2020-02-12 13:03:51 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
SKIP: {
|
|
|
|
skip "Skipping msblob conversion test", 1
|
2020-12-09 18:30:10 +08:00
|
|
|
if disabled($cmd) || $cmd eq 'pkey';
|
2020-02-12 13:03:51 +08:00
|
|
|
|
|
|
|
subtest "$cmd conversions -- public key" => sub {
|
2020-10-15 22:53:29 +08:00
|
|
|
tconversion( -type => 'msb', -prefix => "$cmd-msb-pub",
|
|
|
|
-in => srctop_file("test", "testrsapub.pem"),
|
|
|
|
-args => ["rsa", "-pubin", "-pubout"] );
|
2020-02-12 13:03:51 +08:00
|
|
|
};
|
|
|
|
}
|
2015-04-18 02:13:58 +08:00
|
|
|
}
|