mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-08-11 05:01:19 +02:00
This script calculates the FIPS integrity hash for an already-linked binary offline at build time.
30 lines
908 B
Bash
Executable File
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
|