-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from jackctj117/wolfJSSE_Benchmark
JCE: Implements Bouncy Castle and SunJCE tests with random IV
- Loading branch information
Showing
3 changed files
with
198 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,93 @@ | ||
#!/bin/bash | ||
|
||
# Flag to track if we downloaded BC during this session | ||
BC_DOWNLOADED=false | ||
|
||
# Function to download Bouncy Castle JARs | ||
download_bc_jars() { | ||
local bc_version="1.79" | ||
local lib_dir="../../../lib" | ||
local bc_url="https://downloads.bouncycastle.org/java" | ||
|
||
echo -n "Downloading Bouncy Castle JARs... " | ||
|
||
# Create lib directory if it doesn't exist | ||
mkdir -p "$lib_dir" 2>/dev/null | ||
|
||
# Download both required JARs | ||
if command -v wget >/dev/null; then | ||
wget -q -P "$lib_dir" "$bc_url/bcprov-jdk18on-$bc_version.jar" 2>/dev/null && | ||
wget -q -P "$lib_dir" "$bc_url/bctls-jdk18on-$bc_version.jar" 2>/dev/null || return 1 | ||
elif command -v curl >/dev/null; then | ||
curl -s -L -o "$lib_dir/bcprov-jdk18on-$bc_version.jar" "$bc_url/bcprov-jdk18on-$bc_version.jar" 2>/dev/null && | ||
curl -s -L -o "$lib_dir/bctls-jdk18on-$bc_version.jar" "$bc_url/bctls-jdk18on-$bc_version.jar" 2>/dev/null || return 1 | ||
else | ||
echo "failed" | ||
echo "Error: Neither wget nor curl is available. Please install either wget or curl." | ||
return 1 | ||
fi | ||
|
||
# Verify downloads were successful | ||
if [ -f "$lib_dir/bcprov-jdk18on-$bc_version.jar" ] && [ -f "$lib_dir/bctls-jdk18on-$bc_version.jar" ]; then | ||
echo "done" | ||
BC_DOWNLOADED=true | ||
return 0 | ||
else | ||
echo "failed" | ||
return 1 | ||
fi | ||
} | ||
|
||
# Function to cleanup BC JARs | ||
cleanup_bc_jars() { | ||
local lib_dir="../../../lib" | ||
echo -n "Removing Bouncy Castle JARs... " | ||
rm -f "$lib_dir/bcprov-jdk18on-1.79.jar" "$lib_dir/bctls-jdk18on-1.79.jar" 2>/dev/null | ||
if [ $? -eq 0 ]; then | ||
echo "done" | ||
return 0 | ||
else | ||
echo "failed" | ||
return 1 | ||
fi | ||
} | ||
|
||
cd ./examples/build/provider | ||
|
||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../../../lib/:/usr/local/lib | ||
java -classpath ../../../lib/wolfcrypt-jni.jar:./ -Dsun.boot.library.path=../../../lib/ CryptoBenchmark $@ | ||
|
||
CLASSPATH="../../../lib/wolfcrypt-jni.jar:." | ||
|
||
if [ -f "../../../lib/bcprov-jdk18on-1.79.jar" ] && [ -f "../../../lib/bctls-jdk18on-1.79.jar" ]; then | ||
echo "Running crypto benchmark with Bouncy Castle" | ||
CLASSPATH="$CLASSPATH:../../../lib/bcprov-jdk18on-1.79.jar:../../../lib/bctls-jdk18on-1.79.jar" | ||
else | ||
echo "Bouncy Castle JARs not found in lib directory" | ||
read -p "Would you like to download Bouncy Castle JARs? (y/n) " -n 1 -r | ||
echo | ||
if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
if download_bc_jars; then | ||
echo "Running crypto benchmark with Bouncy Castle" | ||
CLASSPATH="$CLASSPATH:../../../lib/bcprov-jdk18on-1.79.jar:../../../lib/bctls-jdk18on-1.79.jar" | ||
else | ||
echo "Running crypto benchmark without Bouncy Castle due to download failure" | ||
fi | ||
else | ||
echo "Running crypto benchmark without Bouncy Castle" | ||
fi | ||
fi | ||
|
||
# Run the benchmark | ||
java -classpath $CLASSPATH -Dsun.boot.library.path=../../../lib/ CryptoBenchmark $@ | ||
|
||
# After benchmark completion, ask about cleanup if we downloaded the files | ||
if [ "$BC_DOWNLOADED" = true ]; then | ||
echo | ||
read -p "Would you like to remove the downloaded Bouncy Castle JARs? (y/n) " -n 1 -r | ||
echo | ||
if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
cleanup_bc_jars | ||
else | ||
echo "Keeping Bouncy Castle JARs for future use" | ||
fi | ||
fi |