Files
wolfssl/fips-hash.sh
T
Josh Holtrop 83f46f8284 Add fips-hash-offline.sh
This script calculates the FIPS integrity hash for an already-linked
binary offline at build time.
2026-06-22 15:23:28 -04:00

30 lines
908 B
Bash
Executable File

#!/bin/sh
# This script executes the testwolfcrypt binary to report its calculated FIPS
# integrity hash, then it modifies the fips_test.c source code to update the
# expected integrity hash in source.
#
# See fips-hash-offline.sh for a version that calculates the expected FIPS
# integrity hash during the build process on the linked binary. This version is
# suitable for statically linked builds.
if test ! -x ./wolfcrypt/test/testwolfcrypt
then
echo "fips-hash: wolfCrypt test missing"
exit 1
fi
if test ! -s ./wolfcrypt/src/fips_test.c
then
echo "fips-hash: fips_test.c missing"
exit 1
fi
OUT=$(./wolfcrypt/test/testwolfcrypt | sed -n 's/hash = \(.*\)/\1/p')
NEWHASH=$(echo "$OUT" | cut -c1-64)
if test -n "$NEWHASH"
then
cp wolfcrypt/src/fips_test.c wolfcrypt/src/fips_test.c.bak
sed "s/^\".*\";/\"${NEWHASH}\";/" wolfcrypt/src/fips_test.c.bak >wolfcrypt/src/fips_test.c
fi