xref: /freebsd/crypto/openssl/test/recipes/04-test_encoder_decoder.t (revision f126890ac5386406dadf7c4cfa9566cbb56537c5)
1#! /usr/bin/env perl
2# Copyright 2020-2021 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
9use strict;
10use warnings;
11
12use OpenSSL::Test qw/:DEFAULT srctop_dir srctop_file bldtop_dir bldtop_file/;
13use OpenSSL::Test::Utils;
14
15BEGIN {
16    setup("test_encoder_decoder");
17}
18
19use lib srctop_dir('Configurations');
20use lib bldtop_dir('.');
21use platform;
22
23my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
24
25my $rsa_key = srctop_file("test", "certs", "ee-key.pem");
26my $pss_key = srctop_file("test", "certs", "ca-pss-key.pem");
27
28plan tests => ($no_fips ? 0 : 1) + 2;     # FIPS install test + test
29
30my $conf = srctop_file("test", "default.cnf");
31ok(run(test(["endecode_test", "-rsa", $rsa_key,
32                              "-pss", $pss_key,
33                              "-config", $conf,
34                              "-provider", "default"])));
35
36# Run with non-default library context
37ok(run(test(["endecode_test", "-rsa", $rsa_key,
38                              "-pss", $pss_key,
39                              "-context",
40                              "-config", $conf,
41                              "-provider", "default"])));
42
43unless ($no_fips) {
44    # Run with fips library context
45    my $conf = srctop_file("test", "fips-and-base.cnf");
46    ok(run(test(["endecode_test", "-rsa", $rsa_key,
47                                  "-pss", $pss_key,
48                                  "-config", $conf,
49                                  "-provider", "fips"])));
50}
51
52