04-test_encoder_decoder.t 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /usr/bin/env perl
  2. # Copyright 2020-2023 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 OpenSSL::Test qw/:DEFAULT srctop_dir srctop_file bldtop_dir bldtop_file/;
  11. use OpenSSL::Test::Utils;
  12. BEGIN {
  13. setup("test_encoder_decoder");
  14. }
  15. use lib srctop_dir('Configurations');
  16. use lib bldtop_dir('.');
  17. use platform;
  18. my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
  19. my $rsa_key = srctop_file("test", "certs", "ee-key.pem");
  20. my $pss_key = srctop_file("test", "certs", "ca-pss-key.pem");
  21. plan tests => ($no_fips ? 0 : 3) + 2; # FIPS install test + test
  22. my $conf = srctop_file("test", "default.cnf");
  23. ok(run(test(["endecode_test", "-rsa", $rsa_key,
  24. "-pss", $pss_key,
  25. "-config", $conf,
  26. "-provider", "default"])));
  27. # Run with non-default library context
  28. ok(run(test(["endecode_test", "-rsa", $rsa_key,
  29. "-pss", $pss_key,
  30. "-context",
  31. "-config", $conf,
  32. "-provider", "default"])));
  33. unless ($no_fips) {
  34. # Run with fips library context
  35. my $conf = srctop_file("test", "fips-and-base.cnf");
  36. ok(run(test(["endecode_test", "-rsa", $rsa_key,
  37. "-pss", $pss_key,
  38. "-config", $conf,
  39. "-provider", "fips"])));
  40. my $no_des = disabled("des");
  41. SKIP: {
  42. skip "MD5 disabled", 2 if disabled("md5");
  43. ok(run(app([ 'openssl', 'genrsa', '-aes128', '-out', 'epki.pem',
  44. '-traditional', '-passout', 'pass:pass' ])),
  45. "rsa encrypted using a non fips algorithm MD5 in pbe");
  46. my $conf2 = srctop_file("test", "default-and-fips.cnf");
  47. ok(run(test(['decoder_propq_test', '-config', $conf2,
  48. '-provider', 'fips', 'epki.pem'])));
  49. }
  50. }