1# Copyright (c) 2022, Google Inc. 2# 3# Permission to use, copy, modify, and/or distribute this software for any 4# purpose with or without fee is hereby granted, provided that the above 5# copyright notice and this permission notice appear in all copies. 6# 7# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 10# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 12# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 13# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 15# This script attempts to break each of the known KATs and checks that doing so 16# seems to work and at least mentions the correct KAT in the output. 17 18set -x 19set -e 20 21TEST_FIPS_BIN="build/util/fipstools/test_fips" 22 23if [ ! -f $TEST_FIPS_BIN ]; then 24 echo "$TEST_FIPS_BIN is missing. Run this script from the top level of a" 25 echo "BoringSSL checkout and ensure that ./build-fips-break-test-binaries.sh" 26 echo "has been run first." 27 exit 1 28fi 29 30KATS=$(go run util/fipstools/break-kat.go --list-tests) 31 32for kat in $KATS; do 33 go run util/fipstools/break-kat.go $TEST_FIPS_BIN $kat > break-kat-bin 34 chmod u+x ./break-kat-bin 35 if ! (./break-kat-bin 2>&1 >/dev/null || true) | \ 36 egrep -q "^$kat[^a-zA-Z0-9]"; then 37 echo "Failure for $kat did not mention that name in the output" 38 exit 1 39 fi 40 rm ./break-kat-bin 41done 42