15-test_rsa.t 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #! /usr/bin/env perl
  2. # Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License 2.0 (the "License"). You may not use
  5. # this file except in compliance with the License. You can obtain a copy
  6. # in the file LICENSE in the source distribution or at
  7. # https://www.openssl.org/source/license.html
  8. use strict;
  9. use warnings;
  10. use File::Spec;
  11. use OpenSSL::Test qw/:DEFAULT srctop_file/;
  12. use OpenSSL::Test::Utils;
  13. setup("test_rsa");
  14. plan tests => 10;
  15. require_ok(srctop_file('test', 'recipes', 'tconversion.pl'));
  16. ok(run(test(["rsa_test"])), "running rsatest");
  17. run_rsa_tests("pkey");
  18. run_rsa_tests("rsa");
  19. sub run_rsa_tests {
  20. my $cmd = shift;
  21. ok(run(app([ 'openssl', $cmd, '-check', '-in', srctop_file('test', 'testrsa.pem'), '-noout'])),
  22. "$cmd -check" );
  23. SKIP: {
  24. skip "Skipping $cmd conversion test", 3
  25. if disabled("rsa");
  26. subtest "$cmd conversions -- private key" => sub {
  27. tconversion($cmd, srctop_file("test", "testrsa.pem"));
  28. };
  29. subtest "$cmd conversions -- private key PKCS#8" => sub {
  30. tconversion($cmd, srctop_file("test", "testrsa.pem"), "pkey");
  31. };
  32. }
  33. SKIP: {
  34. skip "Skipping msblob conversion test", 1
  35. if disabled($cmd) || disabled("dsa") || $cmd == 'pkey';
  36. subtest "$cmd conversions -- public key" => sub {
  37. tconversion("msb", srctop_file("test", "testrsapub.pem"), "rsa",
  38. "-pubin", "-pubout");
  39. };
  40. }
  41. }