xref: /netbsd-src/external/mpl/bind/dist/bin/tests/system/ecdsa/tests.sh (revision 9689912e6b171cbda866ec33f15ae94a04e2c02d)
1#!/bin/sh
2
3# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4#
5# SPDX-License-Identifier: MPL-2.0
6#
7# This Source Code Form is subject to the terms of the Mozilla Public
8# License, v. 2.0.  If a copy of the MPL was not distributed with this
9# file, you can obtain one at https://mozilla.org/MPL/2.0/.
10#
11# See the COPYRIGHT file distributed with this work for additional
12# information regarding copyright ownership.
13
14set -e
15
16. ../conf.sh
17
18status=0
19n=0
20
21dig_with_opts() {
22  "$DIG" +tcp +noau +noadd +nosea +nostat +nocmd +dnssec -p "$PORT" "$@"
23}
24
25if [ $ECDSAP256SHA256_SUPPORTED = 1 ]; then
26  n=$((n + 1))
27  echo_i "checking that ECDSA256 positive validation works ($n)"
28  ret=0
29  dig_with_opts . @10.53.0.1 soa >dig.out.ns1.test$n || ret=1
30  dig_with_opts . @10.53.0.2 soa >dig.out.ns2.test$n || ret=1
31  $PERL ../digcomp.pl dig.out.ns1.test$n dig.out.ns2.test$n || ret=1
32  grep "flags:.*ad.*QUERY" dig.out.ns2.test$n >/dev/null || ret=1
33  if [ $ret != 0 ]; then echo_i "failed"; fi
34  status=$((status + ret))
35else
36  echo_i "algorithm ECDSA256 not supported, skipping test"
37fi
38
39if [ $ECDSAP384SHA384_SUPPORTED = 1 ]; then
40  n=$((n + 1))
41  echo_i "checking that ECDSA384 positive validation works ($n)"
42  ret=0
43  dig_with_opts . @10.53.0.1 soa >dig.out.ns1.test$n || ret=1
44  dig_with_opts . @10.53.0.3 soa >dig.out.ns3.test$n || ret=1
45  $PERL ../digcomp.pl dig.out.ns1.test$n dig.out.ns3.test$n || ret=1
46  grep "flags:.*ad.*QUERY" dig.out.ns3.test$n >/dev/null || ret=1
47  if [ $ret != 0 ]; then echo_i "failed"; fi
48  status=$((status + ret))
49else
50  echo_i "algorithm ECDSA384 not supported, skipping test"
51fi
52
53echo_i "exit status: $status"
54[ $status -eq 0 ] || exit 1
55