1*66bae5e7Schristos#! /usr/bin/env perl
2*66bae5e7Schristos# Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
3*66bae5e7Schristos#
4*66bae5e7Schristos# Licensed under the Apache License 2.0 (the "License").  You may not use
5*66bae5e7Schristos# this file except in compliance with the License.  You can obtain a copy
6*66bae5e7Schristos# in the file LICENSE in the source distribution or at
7*66bae5e7Schristos# https://www.openssl.org/source/license.html
8*66bae5e7Schristos
9*66bae5e7Schristosuse strict;
10*66bae5e7Schristosuse warnings;
11*66bae5e7Schristos
12*66bae5e7Schristosuse OpenSSL::Test qw/:DEFAULT srctop_dir srctop_file bldtop_dir bldtop_file/;
13*66bae5e7Schristosuse OpenSSL::Test::Utils;
14*66bae5e7Schristos
15*66bae5e7SchristosBEGIN {
16*66bae5e7Schristos    setup("test_encoder_decoder");
17*66bae5e7Schristos}
18*66bae5e7Schristos
19*66bae5e7Schristosuse lib srctop_dir('Configurations');
20*66bae5e7Schristosuse lib bldtop_dir('.');
21*66bae5e7Schristosuse platform;
22*66bae5e7Schristos
23*66bae5e7Schristosmy $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
24*66bae5e7Schristos
25*66bae5e7Schristosmy $rsa_key = srctop_file("test", "certs", "ee-key.pem");
26*66bae5e7Schristosmy $pss_key = srctop_file("test", "certs", "ca-pss-key.pem");
27*66bae5e7Schristos
28*66bae5e7Schristosplan tests => ($no_fips ? 0 : 1) + 2;     # FIPS install test + test
29*66bae5e7Schristos
30*66bae5e7Schristosmy $conf = srctop_file("test", "default.cnf");
31*66bae5e7Schristosok(run(test(["endecode_test", "-rsa", $rsa_key,
32*66bae5e7Schristos                              "-pss", $pss_key,
33*66bae5e7Schristos                              "-config", $conf,
34*66bae5e7Schristos                              "-provider", "default"])));
35*66bae5e7Schristos
36*66bae5e7Schristos# Run with non-default library context
37*66bae5e7Schristosok(run(test(["endecode_test", "-rsa", $rsa_key,
38*66bae5e7Schristos                              "-pss", $pss_key,
39*66bae5e7Schristos                              "-context",
40*66bae5e7Schristos                              "-config", $conf,
41*66bae5e7Schristos                              "-provider", "default"])));
42*66bae5e7Schristos
43*66bae5e7Schristosunless ($no_fips) {
44*66bae5e7Schristos    # Run with fips library context
45*66bae5e7Schristos    my $conf = srctop_file("test", "fips-and-base.cnf");
46*66bae5e7Schristos    ok(run(test(["endecode_test", "-rsa", $rsa_key,
47*66bae5e7Schristos                                  "-pss", $pss_key,
48*66bae5e7Schristos                                  "-config", $conf,
49*66bae5e7Schristos                                  "-provider", "fips"])));
50*66bae5e7Schristos}
51*66bae5e7Schristos
52