setup("test_pkcs8");
-plan tests => 19;
+plan tests => 20;
my $pc5_key = srctop_file('test', 'certs', 'pc5-key.pem');
"read encrypted PKCS#8 from DER form");
};
+subtest 'PKCS#8 -nocrypt reads an unencrypted PKCS#8 PEM' => sub {
+ plan tests => 3;
+
+ # Write an unencrypted PKCS#8 (PrivateKeyInfo) in PEM form.
+ my $p8_pem = 'p8-nocrypt-pem.pem';
+ ok(run(app(['openssl', 'pkcs8', '-topk8', '-nocrypt',
+ '-in', $pc5_key, '-out', $p8_pem])),
+ "write unencrypted PKCS#8 in PEM form");
+ # Read it back with -nocrypt from PEM (the default input format).
+ my $recovered = 'p8-nocrypt-pem-read.pem';
+ ok(run(app(['openssl', 'pkcs8', '-nocrypt',
+ '-in', $p8_pem, '-out', $recovered])),
+ "read unencrypted PKCS#8 from PEM form");
+ is(compare_text($pc5_key, $recovered), 0,
+ "recovered key matches the original");
+};
+
SKIP: {
skip "SM2, SM3 or SM4 is not supported by this OpenSSL build", 3
if disabled("sm2") || disabled("sm3") || disabled("sm4");