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