Skip to content

Commit f407534

Browse files
authored
Ensure enabling local symbols doesn't change the module hash (#2169)
### Description of changes: The original intention of #1005 was to ensure break-kat.go always worked with the library. #1252 then used a side effect to get the module hash but didn't actually fail the build if the hash was different. Turn on `pipefail` so the script exits unsuccessfully if any command fails even in a pipe. Previously if test-break-kat.sh failed the script didn't exit, instead it would continue to the grep which would also fail to find any matching string, and then the `|| true` ensured the script always continued on. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.
1 parent a95190e commit f407534

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

tests/ci/run_fips_tests.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
# SPDX-License-Identifier: Apache-2.0 OR ISC
44

5-
set -ex
5+
set -exo pipefail
66

77
source tests/ci/common_posix_setup.sh
88

@@ -33,23 +33,24 @@ if static_linux_supported || static_openbsd_supported; then
3333

3434
echo "Testing AWS-LC static breakable release build"
3535
run_build -DFIPS=1 -DCMAKE_C_FLAGS="-DBORINGSSL_FIPS_BREAK_TESTS"
36+
./util/fipstools/test-break-kat.sh
3637
export BORINGSSL_FIPS_BREAK_TEST="RSA_PWCT"
3738
${BUILD_ROOT}/crypto/crypto_test --gtest_filter="RSADeathTest.KeygenFailAndDie"
3839
unset BORINGSSL_FIPS_BREAK_TEST
3940

40-
cd $SRC_ROOT
41-
MODULE_HASH=$(./util/fipstools/test-break-kat.sh |\
42-
(egrep "Hash of module was:.* ([a-f0-9]*)" || true))
41+
MODULE_HASH=$(go run util/fipstools/break-hash.go "${BUILD_ROOT}/util/fipstools/test_fips" ./libcrypto.so | \
42+
egrep "Hash of module was:.* ([a-f0-9]*)")
4343

4444
echo "Testing AWS-LC static breakable release build while keeping local symbols"
4545
echo "to check that module hash didn't change."
4646
run_build -DFIPS=1 -DKEEP_ASM_LOCAL_SYMBOLS=1 -DCMAKE_C_FLAGS="-DBORINGSSL_FIPS_BREAK_TESTS"
47-
cd $SRC_ROOT
48-
./util/fipstools/test-break-kat.sh || grep -i hash
49-
MODULE_HASH_LOCALSYMS=$(./util/fipstools/test-break-kat.sh |\
50-
(egrep "Hash of module was:.* ([a-f0-9]*)" || true))
47+
MODULE_HASH_LOCALSYMS=$(go run util/fipstools/break-hash.go "${BUILD_ROOT}/util/fipstools/test_fips" ./libcrypto.so | \
48+
egrep "Hash of module was:.* ([a-f0-9]*)")
5149
if [ "$MODULE_HASH" == "$MODULE_HASH_LOCALSYMS" ]; then
5250
echo "Module hash didn't change"
51+
else
52+
echo "Module hashed changed with local symbols unexpectedly"
53+
exit 1
5354
fi
5455

5556
# These build parameters may be needed by our aws-lc-fips-sys Rust package

0 commit comments

Comments
 (0)