Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 17 additions & 21 deletions fips-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ GIT="${GIT:-git -c advice.detachedHead=false}"
TEST_DIR="${TEST_DIR:-XXX-fips-test}"
FLAVOR="${FLAVOR:-linux}"
KEEP="${KEEP:-no}"
MAKECHECK=${MAKECHECK:-yes}
FIPS_REPO="${FIPS_REPO:-git@github.com:wolfssl/fips.git}"

Usage() {
Expand All @@ -39,7 +40,9 @@ usageText
}

while [ "$1" ]; do
if [ "$1" = 'keep' ]; then KEEP='yes'; else FLAVOR="$1"; fi
if [ "$1" = 'keep' ]; then KEEP='yes';
elif [ "$1" = 'nomakecheck' ]; then MAKECHECK='no';
else FLAVOR="$1"; fi
shift
done

Expand Down Expand Up @@ -262,8 +265,7 @@ esac
function checkout_files() {
local name
local tag
for file_entry in "$@"
do
for file_entry in "$@"; do
name=${file_entry%%:*}
tag=${file_entry#*:}
if ! $GIT rev-parse -q --verify "my$tag" >/dev/null
Expand All @@ -283,14 +285,12 @@ function copy_fips_files() {
local bname
local dname
local tag
for file_entry in "$@"
do
for file_entry in "$@"; do
name=${file_entry%%:*}
tag=${file_entry#*:}
bname=$(basename "$name")
dname=$(dirname "$name")
if ! $GIT rev-parse -q --verify "my$tag" >/dev/null
then
if ! $GIT rev-parse -q --verify "my$tag" >/dev/null; then
$GIT branch --no-track "my$tag" "$tag" || exit $?
fi
$GIT checkout "my$tag" -- "$bname" || exit $?
Expand All @@ -305,8 +305,7 @@ fi

pushd "$TEST_DIR" || exit 2

if ! $GIT clone "$FIPS_REPO" fips
then
if ! $GIT clone "$FIPS_REPO" fips; then
echo "fips-check: Couldn't check out FIPS repository."
exit 1
fi
Expand All @@ -322,8 +321,7 @@ popd || exit 2
# Since OE additions can still be processed for cert3389 we will call 140-2
# ready "fipsv2-OE-ready" indicating it is ready to use for an OE addition but
# would not be good for a new certification effort with the latest files.
if [ "$FLAVOR" = 'fipsv2-OE-ready' ] && [ -s wolfcrypt/src/fips.c ]
then
if [ "$FLAVOR" = 'fipsv2-OE-ready' ] && [ -s wolfcrypt/src/fips.c ]; then
cp wolfcrypt/src/fips.c wolfcrypt/src/fips.c.bak
sed "s/v4.0.0-alpha/fipsv2-OE-ready/" wolfcrypt/src/fips.c.bak >wolfcrypt/src/fips.c
fi
Expand All @@ -343,14 +341,12 @@ cavp-selftest-v2)
;;
esac

if ! $MAKE
then
if ! $MAKE; then
echo 'fips-check: Make failed. Debris left for analysis.'
exit 3
fi

if [ -s wolfcrypt/src/fips_test.c ]
then
if [ -s wolfcrypt/src/fips_test.c ]; then
NEWHASH=$(./wolfcrypt/test/testwolfcrypt | sed -n 's/hash = \(.*\)/\1/p')
if [ -n "$NEWHASH" ]; then
cp wolfcrypt/src/fips_test.c wolfcrypt/src/fips_test.c.bak
Expand All @@ -359,15 +355,15 @@ then
fi
fi

if ! $MAKE check
then
echo 'fips-check: Test failed. Debris left for analysis.'
exit 3
if [ "$MAKECHECK" = "yes" ]; then
if ! $MAKE check; then
echo 'fips-check: Test failed. Debris left for analysis.'
exit 3
fi
fi

# Clean up
popd || exit 2
if [ "$KEEP" = 'no' ];
then
if [ "$KEEP" = 'no' ]; then
rm -rf "$TEST_DIR"
fi