xref: /freebsd/crypto/openssl/test/recipes/06-test_algorithmid.t (revision e7be843b4a162e68651d3911f0357ed464915629)
1e0c4386eSCy Schubert#! /usr/bin/env perl
2e0c4386eSCy Schubert
3*e7be843bSPierre Pronchery# Copyright 2018-2023 The OpenSSL Project Authors. All Rights Reserved.
4e0c4386eSCy Schubert#
5e0c4386eSCy Schubert# Licensed under the Apache License 2.0 (the "License").  You may not use
6e0c4386eSCy Schubert# this file except in compliance with the License.  You can obtain a copy
7e0c4386eSCy Schubert# in the file LICENSE in the source distribution or at
8e0c4386eSCy Schubert# https://www.openssl.org/source/license.html
9e0c4386eSCy Schubert
10e0c4386eSCy Schubertuse strict;
11e0c4386eSCy Schubert
12e0c4386eSCy Schubertuse OpenSSL::Test qw(:DEFAULT srctop_file);
13e0c4386eSCy Schubertuse OpenSSL::Test::Utils;
14e0c4386eSCy Schubert
15e0c4386eSCy Schubertsetup("test_algorithmid");
16e0c4386eSCy Schubert
17e0c4386eSCy Schubert# eecert => cacert
18e0c4386eSCy Schubertmy %certs_info =
19e0c4386eSCy Schubert    (
20e0c4386eSCy Schubert     'ee-cert' => 'ca-cert',
21e0c4386eSCy Schubert     'ee-cert2' => 'ca-cert2',
22e0c4386eSCy Schubert
23e0c4386eSCy Schubert     # 'ee-pss-sha1-cert' => 'ca-cert',
24e0c4386eSCy Schubert     # 'ee-pss-sha256-cert' => 'ca-cert',
25e0c4386eSCy Schubert     # 'ee-pss-cert' => 'ca-pss-cert',
26e0c4386eSCy Schubert     # 'server-pss-restrict-cert' => 'rootcert',
27e0c4386eSCy Schubert
28e0c4386eSCy Schubert     (
29e0c4386eSCy Schubert      disabled('ec')
30e0c4386eSCy Schubert      ? ()
31e0c4386eSCy Schubert      : (
32e0c4386eSCy Schubert         'ee-cert-ec-explicit' => 'ca-cert-ec-named',
33e0c4386eSCy Schubert         'ee-cert-ec-named-explicit' => 'ca-cert-ec-explicit',
34e0c4386eSCy Schubert         'ee-cert-ec-named-named' => 'ca-cert-ec-named',
35e0c4386eSCy Schubert         # 'server-ed448-cert' => 'root-ed448-cert'
36e0c4386eSCy Schubert         'server-ecdsa-brainpoolP256r1-cert' => 'rootcert',
37e0c4386eSCy Schubert        )
38e0c4386eSCy Schubert     )
39e0c4386eSCy Schubert    );
40e0c4386eSCy Schubertmy @pubkeys =
41e0c4386eSCy Schubert    (
42e0c4386eSCy Schubert     'testrsapub',
43e0c4386eSCy Schubert     disabled('dsa') ? () : 'testdsapub',
44*e7be843bSPierre Pronchery     disabled('ec') ? () : qw(testecpub-p256),
45*e7be843bSPierre Pronchery     disabled('ecx') ? () : qw(tested25519pub tested448pub)
46e0c4386eSCy Schubert    );
47e0c4386eSCy Schubertmy @certs = sort keys %certs_info;
48e0c4386eSCy Schubert
49e0c4386eSCy Schubertplan tests =>
50e0c4386eSCy Schubert    scalar @certs
51e0c4386eSCy Schubert    + scalar @pubkeys;
52e0c4386eSCy Schubert
53e0c4386eSCy Schubertforeach (@certs) {
54e0c4386eSCy Schubert    ok(run(test(['algorithmid_test', '-x509',
55e0c4386eSCy Schubert                 srctop_file('test', 'certs', "$_.pem"),
56e0c4386eSCy Schubert                 srctop_file('test', 'certs', "$certs_info{$_}.pem")])));
57e0c4386eSCy Schubert}
58e0c4386eSCy Schubert
59e0c4386eSCy Schubertforeach (sort @pubkeys) {
60e0c4386eSCy Schubert    ok(run(test(['algorithmid_test', '-spki', srctop_file('test', "$_.pem")])));
61e0c4386eSCy Schubert}
62