Skip to content

Commit e5ebdd5

Browse files
committed
F-3763: fail closed when no SHA-256 tool is available in CryptoBenchmark.sh
1 parent 546fb46 commit e5ebdd5

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

examples/provider/CryptoBenchmark.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ verify_sha256() {
2020
elif command -v shasum >/dev/null; then
2121
actual=$(shasum -a 256 "$file" | awk '{print $1}')
2222
else
23-
echo "Warning: no sha256sum or shasum available, skipping hash verification"
24-
return 0
23+
echo "Error: no sha256sum or shasum found, refusing unverified $file"
24+
rm -f "$file"
25+
return 1
2526
fi
2627

2728
if [ "$actual" != "$expected" ]; then
@@ -40,6 +41,13 @@ download_bc_jars() {
4041
local lib_dir="$LIB_DIR"
4142
local bc_url="https://repo1.maven.org/maven2/org/bouncycastle"
4243

44+
# Require a SHA-256 tool before any download, JARs are only added to the
45+
# classpath after hash verification
46+
if ! command -v sha256sum >/dev/null && ! command -v shasum >/dev/null; then
47+
echo "failed (no sha256sum or shasum for hash verification)"
48+
return 1
49+
fi
50+
4351
echo -n "Downloading Bouncy Castle JARs (version $bc_version)... "
4452
mkdir -p "$lib_dir" || {
4553
echo "failed (cannot create $lib_dir)"

0 commit comments

Comments
 (0)