#!/bin/bash # fips-check.sh # This script checks the current revision of the code against the # previous release of the FIPS code. While wolfSSL and wolfCrypt # may be advancing, they must work correctly with the last tested # copy of our FIPS approved code. # # This should check out all the approved flavors. The command line # option selects the flavor. # # $ ./fips-check [flavor] [keep] # # - flavor: linux (default), ios, android, windows, freertos, linux-ecc, netbsd-selftest, linuxv2, fipsv2-OE-ready, fips-ready, stm32l4-v2, linuxv5, linuxv5-ready, linuxv5-dev # # - keep: (default off) XXX-fips-test temp dir around for inspection # Usage() { cat <"${CRYPT_SRC_PATH}/fips.c" fi # run the make test ./autogen.sh if [ "$CAVP_SELFTEST_ONLY" == "yes" ]; then if [ "$CAVP_SELFTEST_OPTION" == "v2" ] then ./configure --enable-selftest=v2 else ./configure --enable-selftest fi else ./configure --enable-fips=$FIPS_OPTION fi if ! $MAKE; then echo "fips-check: Make failed. Debris left for analysis." exit 3 fi if [ "$CAVP_SELFTEST_ONLY" == "no" ]; then NEWHASH=$(./wolfcrypt/test/testwolfcrypt | sed -n 's/hash = \(.*\)/\1/p') if [ -n "$NEWHASH" ]; then cp "${CRYPT_SRC_PATH}/fips_test.c" "${CRYPT_SRC_PATH}/fips_test.c.bak" sed "s/^\".*\";/\"${NEWHASH}\";/" "${CRYPT_SRC_PATH}/fips_test.c.bak" >"${CRYPT_SRC_PATH}/fips_test.c" make clean fi fi if ! $MAKE test; then echo "fips-check: Test failed. Debris left for analysis." exit 3 fi if [ ${#FIPS_CONFLICTS[@]} -ne 0 ]; then echo "Due to the way this package is compiled by the customer duplicate" echo "source file names are an issue, renaming:" for FNAME in "${FIPS_CONFLICTS[@]}" do echo "wolfcrypt/src/$FNAME.c to wolfcrypt/src/wc_$FNAME.c" mv "./wolfcrypt/src/$FNAME.c" "./wolfcrypt/src/wc_$FNAME.c" done echo "Confirming files were renamed..." ls -la ./wolfcrypt/src/wc_*.c fi # Clean up popd || exit 2 if [ "$KEEP" == "no" ]; then rm -rf "$TEST_DIR" fi