mirror of
https://github.com/openssl/openssl.git
synced 2024-11-27 03:54:14 +08:00
test: Add test cases for req -cipher option
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/25796)
This commit is contained in:
parent
bca1bb2977
commit
7e3f7f1dbb
@ -15,7 +15,7 @@ use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
||||
|
||||
setup("test_req");
|
||||
|
||||
plan tests => 110;
|
||||
plan tests => 111;
|
||||
|
||||
require_ok(srctop_file('test', 'recipes', 'tconversion.pl'));
|
||||
|
||||
@ -355,6 +355,56 @@ subtest "generating SM2 certificate requests" => sub {
|
||||
}
|
||||
};
|
||||
|
||||
subtest "generating certificate requests with -cipher flag" => sub {
|
||||
plan tests => 6;
|
||||
|
||||
diag("Testing -cipher flag with aes-256-cbc...");
|
||||
ok(run(app(["openssl", "req",
|
||||
"-config", srctop_file("test", "test.cnf"),
|
||||
"-newkey", "rsa:2048",
|
||||
"-keyout", "privatekey-aes256.pem",
|
||||
"-out", "testreq-rsa-cipher.pem",
|
||||
"-utf8",
|
||||
"-cipher", "aes-256-cbc",
|
||||
"-passout", "pass:password"])),
|
||||
"Generating request with -cipher flag (AES-256-CBC)");
|
||||
|
||||
diag("Verifying signature for aes-256-cbc...");
|
||||
ok(run(app(["openssl", "req",
|
||||
"-config", srctop_file("test", "test.cnf"),
|
||||
"-verify", "-in", "testreq-rsa-cipher.pem", "-noout"])),
|
||||
"Verifying signature on request with -cipher (AES-256-CBC)");
|
||||
|
||||
open my $fh, '<', "privatekey-aes256.pem" or BAIL_OUT("Could not open key file: $!");
|
||||
my $first_line = <$fh>;
|
||||
close $fh;
|
||||
ok($first_line =~ /^-----BEGIN ENCRYPTED PRIVATE KEY-----/,
|
||||
"Check that the key file is encrypted (AES-256-CBC)");
|
||||
|
||||
diag("Testing -cipher flag with aes-128-cbc...");
|
||||
ok(run(app(["openssl", "req",
|
||||
"-config", srctop_file("test", "test.cnf"),
|
||||
"-newkey", "rsa:2048",
|
||||
"-keyout", "privatekey-aes128.pem",
|
||||
"-out", "testreq-rsa-cipher-aes128.pem",
|
||||
"-utf8",
|
||||
"-cipher", "aes-128-cbc",
|
||||
"-passout", "pass:password"])),
|
||||
"Generating request with -cipher flag (AES-128-CBC)");
|
||||
|
||||
diag("Verifying signature for aes-128-cbc...");
|
||||
ok(run(app(["openssl", "req",
|
||||
"-config", srctop_file("test", "test.cnf"),
|
||||
"-verify", "-in", "testreq-rsa-cipher-aes128.pem", "-noout"])),
|
||||
"Verifying signature on request with -cipher (AES-128-CBC)");
|
||||
|
||||
open my $fh_aes128, '<', "privatekey-aes128.pem" or BAIL_OUT("Could not open key file: $!");
|
||||
my $first_line_aes128 = <$fh_aes128>;
|
||||
close $fh_aes128;
|
||||
ok($first_line_aes128 =~ /^-----BEGIN ENCRYPTED PRIVATE KEY-----/,
|
||||
"Check that the key file is encrypted (AES-128-CBC)");
|
||||
};
|
||||
|
||||
my @openssl_args = ("req", "-config", srctop_file("apps", "openssl.cnf"));
|
||||
|
||||
run_conversion('req conversions',
|
||||
|
@ -50,7 +50,6 @@ emailAddress = optional
|
||||
####################################################################
|
||||
[ req ]
|
||||
distinguished_name = req_distinguished_name
|
||||
encrypt_rsa_key = no
|
||||
|
||||
# Make altreq be identical to req
|
||||
[ altreq ]
|
||||
|
Loading…
Reference in New Issue
Block a user