Skip to content

Commit

Permalink
Moved DH test to last in benchmark, changed JCE provider removal in m…
Browse files Browse the repository at this point in the history
…ain()
  • Loading branch information
Jack Tjaden committed Feb 28, 2025
1 parent 4703483 commit 6f6adf1
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions examples/provider/CryptoBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -604,26 +604,6 @@ public static void main(String[] args) {
}
}

System.out.println("\n-----------------------------------------------------------------------------");
System.out.println("DH Benchmark Results");
System.out.println("-----------------------------------------------------------------------------");

for (Provider provider : providers) {
if (provider instanceof WolfCryptProvider && !FeatureDetect.DhEnabled()) {
continue;
}
Security.insertProviderAt(provider, 1);
System.out.println("\n" + provider.getName() + ":");
for (int keySize : DH_KEY_SIZES) {
try {
runDHBenchmark(provider.getName(), keySize);
} catch (Exception e) {
System.out.printf("Failed to benchmark DH %d with provider %s: %s%n",
keySize, provider.getName(), e.getMessage());
}
}
}

/* Run RSA benchmarks */
System.out.println("\n-----------------------------------------------------------------------------");
System.out.println("RSA Benchmark Results");
Expand Down Expand Up @@ -656,7 +636,6 @@ public static void main(String[] args) {
curve, provider.getName(), e.getMessage());
}
}
Security.removeProvider(provider.getName());
}

System.out.println("\n-----------------------------------------------------------------------------");
Expand All @@ -681,8 +660,26 @@ public static void main(String[] args) {
if (FeatureDetect.HmacSha512Enabled()) {
runHmacBenchmark("HmacSHA512", providerNames[i]);
}
}

System.out.println("\n-----------------------------------------------------------------------------");
System.out.println("DH Benchmark Results");
System.out.println("-----------------------------------------------------------------------------");

Security.removeProvider(providers[i].getName());
for (Provider provider : providers) {
if (provider instanceof WolfCryptProvider && !FeatureDetect.DhEnabled()) {
continue;
}
Security.insertProviderAt(provider, 1);
System.out.println("\n" + provider.getName() + ":");
for (int keySize : DH_KEY_SIZES) {
try {
runDHBenchmark(provider.getName(), keySize);
} catch (Exception e) {
System.out.printf("Failed to benchmark DH %d with provider %s: %s%n",
keySize, provider.getName(), e.getMessage());
}
}
}

System.out.println("-----------------------------------------------------------------------------\n");
Expand Down

0 comments on commit 6f6adf1

Please sign in to comment.