xref: /openssl/test/recipes/20-test_spkac.t (revision 02288cbb)
1#! /usr/bin/env perl
2# Copyright 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 File::Spec;
13use File::Basename;
14use OpenSSL::Test qw/:DEFAULT srctop_file ok_nofips/;
15use OpenSSL::Test::Utils;
16
17setup("test_spkac");
18
19plan skip_all => "RSA is not supported by this OpenSSL build"
20    if disabled("rsa");
21
22plan tests => 4;
23
24# For the tests below we use the cert itself as the TBS file
25
26SKIP: {
27    skip "MD5 is not supported by this OpenSSL build", 2
28        if disabled("md5");
29
30    ok(run(app([ 'openssl', 'spkac', '-key', srctop_file("test", "testrsa.pem"),
31                 '-out', 'spkac-md5.pem'])),
32               "SPKAC MD5");
33    ok(run(app([ 'openssl', 'spkac', '-in', 'spkac-md5.pem'])),
34               "SPKAC MD5 verify");
35}
36
37ok(run(app([ 'openssl', 'spkac', '-key', srctop_file("test", "testrsa.pem"),
38             '-out', 'spkac-sha256.pem', '-digest', 'sha256'])),
39           "SPKAC SHA256");
40ok(run(app([ 'openssl', 'spkac', '-in', 'spkac-sha256.pem'])),
41           "SPKAC SHA256 verify");
42