Skip to content

Commit

Permalink
Changed RSA_TIME variable to more generic TEST_TIME
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Tjaden committed Mar 4, 2025
1 parent 6f6adf1 commit bd82709
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions examples/provider/CryptoBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class CryptoBenchmark {
private static final int DES3_BLOCK_SIZE = 8;
private static final int GCM_TAG_LENGTH = 128;
private static final int[] RSA_KEY_SIZES = {2048, 3072, 4096};
private static final int RSA_MIN_TIME_SECONDS = 1; /* minimum time to run each test */
private static final int TEST_MIN_TIME_SECONDS = 1; /* minimum time to run each test */
private static final int SMALL_MESSAGE_SIZE = 32; /* small message size for RSA ops */
private static final String[] ECC_CURVES = {"secp256r1"}; /* Can add more curves benchmark.c only uses secp256r1 */
private static final int[] DH_KEY_SIZES = {2048}; /* Can add more key sizes benchmark.c only uses 2048 */
Expand Down Expand Up @@ -357,7 +357,7 @@ private static void runRSABenchmark(String providerName, int keySize) throws Exc
keyGen.generateKeyPair();
keyGenOps++;
elapsedTime = (System.nanoTime() - startTime) / 1_000_000_000.0;
} while (elapsedTime < RSA_MIN_TIME_SECONDS);
} while (elapsedTime < TEST_MIN_TIME_SECONDS);

keyGenOp = String.format("RSA %d key gen", keySize);
printKeyGenResults(keyGenOps, elapsedTime, keyGenOp, providerName, cipherMode);
Expand All @@ -376,7 +376,7 @@ private static void runRSABenchmark(String providerName, int keySize) throws Exc
cipher.doFinal(testData);
publicOps++;
elapsedTime = (System.nanoTime() - startTime) / 1_000_000_000.0;
} while (elapsedTime < RSA_MIN_TIME_SECONDS);
} while (elapsedTime < TEST_MIN_TIME_SECONDS);

printKeyGenResults(publicOps, elapsedTime, "RSA 2048 public", providerName, cipherMode);

Expand All @@ -392,7 +392,7 @@ private static void runRSABenchmark(String providerName, int keySize) throws Exc
cipher.doFinal(encrypted);
privateOps++;
elapsedTime = (System.nanoTime() - startTime) / 1_000_000_000.0;
} while (elapsedTime < RSA_MIN_TIME_SECONDS);
} while (elapsedTime < TEST_MIN_TIME_SECONDS);

printKeyGenResults(privateOps, elapsedTime, "RSA 2048 private", providerName, cipherMode);
}
Expand Down Expand Up @@ -423,7 +423,7 @@ private static void runECCBenchmark(String providerName, String curveName) throw
keyGen.generateKeyPair();
keyGenOps++;
elapsedTime = (System.nanoTime() - startTime) / 1_000_000_000.0;
} while (elapsedTime < RSA_MIN_TIME_SECONDS);
} while (elapsedTime < TEST_MIN_TIME_SECONDS);

String keyGenOp = String.format("ECC %s key gen", curveName);
printKeyGenResults(keyGenOps, elapsedTime, keyGenOp, providerName, "EC");
Expand Down Expand Up @@ -523,7 +523,7 @@ private static void runDHBenchmark(String providerName, int keySize) throws Exce
keyGen.generateKeyPair();
keyGenOps++;
elapsedTime = (System.nanoTime() - startTime) / 1_000_000_000.0;
} while (elapsedTime < RSA_MIN_TIME_SECONDS);
} while (elapsedTime < TEST_MIN_TIME_SECONDS);

String keyGenOp = String.format("DH %d key gen", keySize);
printKeyGenResults(keyGenOps, elapsedTime, keyGenOp, providerName, DH_ALGORITHM);
Expand All @@ -545,7 +545,7 @@ private static void runDHBenchmark(String providerName, int keySize) throws Exce
keyAgreement.generateSecret();
agreementOps++;
elapsedTime = (System.nanoTime() - startTime) / 1_000_000_000.0;
} while (elapsedTime < RSA_MIN_TIME_SECONDS);
} while (elapsedTime < TEST_MIN_TIME_SECONDS);

String agreementOp = String.format("DH %d agree", keySize);
printKeyGenResults(agreementOps, elapsedTime, agreementOp, providerName, DH_ALGORITHM);
Expand Down

0 comments on commit bd82709

Please sign in to comment.