examples
Class CipherBenchmark

java.lang.Object
  extended by examples.CipherBenchmark

public class CipherBenchmark
extends java.lang.Object

Benchmark the different encryption algorithms. The code as shipped tests the MindTerm implementations of the algorithms. By uncommenting relevant portions, and building with Java 1.4 or later, it is possible to also benchmark some of the implementations in the Java runtime.

Usage: java -cp examples.jar examples.CipherBenchmark


Constructor Summary
CipherBenchmark()
           
 
Method Summary
static void bench(java.lang.String name, java.lang.String cipher, boolean encrypt, int keylen, int blocksize)
          Benchmark an algorithm
static void benchHash(java.lang.String name, java.lang.String algorithm, int blocksize)
          Benchmark an hash algorithm
static void benchHashSizes(java.lang.String name, java.lang.String algorithm)
           
static void benchMac(java.lang.String name, java.lang.String algorithm, int keylen, int blocksize)
          Benchmark an hmac algorithm
static void benchMac14(java.lang.String name, java.lang.String algorithm, int keylen, int blocksize)
          Benchmark an hmac algorithm in the java runtime
static void benchMacSizes(java.lang.String name, java.lang.String algorithm, int keylen)
           
static void benchMacSizes14(java.lang.String name, java.lang.String algorithm, int keylen)
           
static void main(java.lang.String[] argv)
          Run the benchmark
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CipherBenchmark

public CipherBenchmark()
Method Detail

bench

public static void bench(java.lang.String name,
                         java.lang.String cipher,
                         boolean encrypt,
                         int keylen,
                         int blocksize)
                  throws GeneralSecurityException
Benchmark an algorithm

Parameters:
name - name to print when presenting result
cipher - formal name of algorithm to test
encrypt - true to encrypt and false to decrypt
keylen - length of keys (bytes)
blocksize - length of block to encrypt (bytes)
Throws:
GeneralSecurityException

benchHash

public static void benchHash(java.lang.String name,
                             java.lang.String algorithm,
                             int blocksize)
                      throws GeneralSecurityException
Benchmark an hash algorithm

Parameters:
name - name to print when presenting result
algorithm - formal name of algorithm to test
blocksize - length of block to operate on
Throws:
GeneralSecurityException

benchHashSizes

public static void benchHashSizes(java.lang.String name,
                                  java.lang.String algorithm)
                           throws GeneralSecurityException
Throws:
GeneralSecurityException

benchMac

public static void benchMac(java.lang.String name,
                            java.lang.String algorithm,
                            int keylen,
                            int blocksize)
                     throws GeneralSecurityException
Benchmark an hmac algorithm

Parameters:
name - name to print when presenting result
algorithm - formal name of algorithm to test
keylen - length of keys (bytes)
blocksize - length of block to operate on
Throws:
GeneralSecurityException

benchMacSizes

public static void benchMacSizes(java.lang.String name,
                                 java.lang.String algorithm,
                                 int keylen)
                          throws GeneralSecurityException
Throws:
GeneralSecurityException

benchMac14

public static void benchMac14(java.lang.String name,
                              java.lang.String algorithm,
                              int keylen,
                              int blocksize)
                       throws java.lang.Exception
Benchmark an hmac algorithm in the java runtime

Parameters:
name - name to print when presenting result
algorithm - formal name of algorithm to test
keylen - length of keys (bytes)
blocksize - length of block to operate on
Throws:
java.lang.Exception

benchMacSizes14

public static void benchMacSizes14(java.lang.String name,
                                   java.lang.String algorithm,
                                   int keylen)
                            throws java.lang.Exception
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] argv)
Run the benchmark