Skip to content

Common cryptography benchmarking of algorithms between OpenSSL Jostle provider and Bouncy Castle provider

Notifications You must be signed in to change notification settings

ngkore/jostle-bc-crypto-benchmarking

Repository files navigation

Crypto Performance Benchmarks

JMH benchmarking suite comparing cryptographic performance between Bouncy Castle (BC) and OpenSSL Jostle providers.

Supported Algorithms

  • Symmetric: AES, ARIA, Camellia, SM4 (AEAD, Block, Stream modes)
  • KDF: PBKDF2 (SHA2, SHA3, SM3) and Scrypt
  • Post-Quantum: ML-DSA, ML-KEM, SLH-DSA (NIST variants)

Prerequisites

Java 25+

Download from the OpenJDK download page.

wget https://download.java.net/java/GA/jdk25.0.1/2fbf10d8c78e40bd87641c434705079d/8/GPL/openjdk-25.0.1_linux-x64_bin.tar.gz

# Create directory for Java installation
sudo mkdir -p /opt/java

# Extract the tar.gz file to /opt/java
sudo tar -xzf openjdk-25.0.1_linux-x64_bin.tar.gz -C /opt/java

# Rename for easier access (optional)
sudo mv /opt/java/jdk-25.0.1 /opt/java/jdk-25

Configure JAVA_HOME and PATH variables:

# Add to ~/.bashrc
export JAVA_HOME=/opt/java/jdk-25
export PATH=$PATH:$JAVA_HOME/bin

# Apply changes
source ~/.bashrc

Node.js 20+ (for Visualizer)

Required only if you want to run the visualizer locally.

# Using nvm (recommended)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install 20
nvm use 20

Setup

1. Provider JARs

Place the following provider JARs in the libs/ directory:

  • bcprov-jdk18on-*.jar (from Bouncy Castle)
  • openssl-jostle-*.jar (from Jostle provider)

Note

Follow ngkore/jostle and ngkore/bouncy-castle-java for instructions on how to build the Jostle and Bouncy Castle provider.

2. Native Library Paths

The Jostle provider requires OpenSSL and its own JNI libraries. Edit scripts/run_benchmarks.sh and update the DEFAULT_NATIVE_LIB_PATH variable to match your environment:

# Example in scripts/run_benchmarks.sh
DEFAULT_NATIVE_LIB_PATH="/path/to/openssl/libssl.so:/path/to/jostle/libinterface_jni.so"

If you don't know the paths, use the find command:

OpenSSL (look for libssl.so):

find /usr -name "libssl.so*" 2>/dev/null
# Or typical local install:
find /home -name "libssl.so*" 2>/dev/null

Output:

ubuntu@vm01:~$ find /home -name "libssl.so*" 2>/dev/null
/home/ubuntu/openssl-3.6.0/libssl.so.3
/home/ubuntu/openssl-3.6.0/libssl.so
/home/ubuntu/openssl_3_6/lib64/libssl.so.3
/home/ubuntu/openssl_3_6/lib64/libssl.so

Jostle (look for libinterface_jni.so):

find / -name "libinterface_jni.so" 2>/dev/null

Output:

ubuntu@vm01:~$ find / -name "libinterface_jni.so" 2>/dev/null
/home/ubuntu/bouncy-jostle/openssl-jostle/jostle/src/main/resources/native/linux/x86_64/libinterface_jni.so
/home/ubuntu/bouncy-jostle/openssl-jostle/jostle/bin/main/native/linux/x86_64/libinterface_jni.so
/home/ubuntu/bouncy-jostle/openssl-jostle/jostle/build/resources/main/native/linux/x86_64/libinterface_jni.so
/home/ubuntu/bouncy-jostle/openssl-jostle/interface/libinterface_jni.so

Use /home/ubuntu/openssl_3_6/lib64:/home/ubuntu/bouncy-jostle/openssl-jostle/jostle/build/resources/main/native/linux/x86_64 for the DEFAULT_NATIVE_LIB_PATH.

Running Benchmarks

Use the provided script to execute benchmarks. It handles configuration, native paths, and logging.

./scripts/run_benchmarks.sh

Outputs

  • JSON Results: build/results/jmh/results.json (for analysis)
  • Execution Log: build/results/jmh/benchmark_run.log (terminal output)

Configuration

Configuration is centrally managed in scripts/run_benchmarks.sh.

Parameter Description Default
WARMUP Number of warmup iterations 2
ITERATIONS Number of measurement iterations 3
TIME Duration of each iteration "5s"
FORK Number of fresh JVM forks 1
MODE JMH Mode (thrpt, avgt, sample, ss) "thrpt"

Visualizer

A React-based web application for visualizing benchmark results with interactive charts and tables.

Local Development

cd visualizer
npm install
npm run dev

The visualizer automatically loads results from results/results.json via symlink. After running benchmarks, start the visualizer to see the comparison between BC and Jostle performance.

Production Build

npm run build

The built files will be in visualizer/dist/.

Live Demo

The visualizer is automatically deployed to GitHub Pages when changes are pushed to visualizer/ or results/ on the main branch.

About

Common cryptography benchmarking of algorithms between OpenSSL Jostle provider and Bouncy Castle provider

Topics

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •