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