Skip to content

Commit 92dbe19

Browse files
committed
Changed algorithm names to lower case when searching and changed excpetion handling
1 parent 46879b5 commit 92dbe19

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

examples/provider/CryptoBenchmark.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -727,14 +727,17 @@ private static void runSignatureBenchmark(String algorithm, String providerName)
727727
String signatureProvider = providerName;
728728
String keyType;
729729

730+
/* Convert algorithm to lowercase for case-insensitive matching */
731+
String algorithmLower = algorithm.toLowerCase();
732+
730733
/* Handle both wolfJCE format (withRSA) and BC format (WITHRSA) */
731-
if (algorithm.contains("withRSA") || algorithm.contains("WITHRSA")) {
734+
if (algorithmLower.contains("withrsa")) {
732735
keyType = "RSA";
733736
if (providerName.equals("SunJCE")) {
734737
keyGenProvider = "SunRsaSign";
735738
signatureProvider = "SunRsaSign";
736739
}
737-
} else if (algorithm.contains("withECDSA") || algorithm.contains("WITHECDSA")) {
740+
} else if (algorithmLower.contains("withecdsa")) {
738741
keyType = "EC";
739742
if (providerName.equals("SunJCE")) {
740743
/* Use SunEC if available, otherwise fall back to what's available */
@@ -746,7 +749,7 @@ private static void runSignatureBenchmark(String algorithm, String providerName)
746749
throw new Exception("SunEC provider not available for ECDSA operations");
747750
}
748751
}
749-
} else if (algorithm.contains("withDSA") || algorithm.contains("WITHDSA")) {
752+
} else if (algorithmLower.contains("withdsa")) {
750753
keyType = "DSA";
751754
if (providerName.equals("SunJCE")) {
752755
keyGenProvider = "SUN";
@@ -817,9 +820,9 @@ private static void runSignatureBenchmark(String algorithm, String providerName)
817820
results.add(new BenchmarkResult(signatureProvider, algorithm + " verify", verifyOpsPerSec));
818821

819822
} catch (Exception e) {
820-
System.out.printf(" %-40s Not supported: %s%n",
821-
algorithm + " (" + signatureProvider + ")", e.getMessage(), e.getClass().getName());
822-
e.printStackTrace(System.out);
823+
System.err.printf(" %-40s Not supported: %s (%s)%n",
824+
algorithm + " (" + signatureProvider + ")", e.getMessage(),
825+
e.getClass().getName());
823826
}
824827
}
825828

0 commit comments

Comments
 (0)