Class AsymmetricKeyPreCalculator

java.lang.Object
net.messagevortex.asn1.AsymmetricKeyPreCalculator
All Implemented Interfaces:
Serializable, Callable<Integer>

public class AsymmetricKeyPreCalculator extends Object implements Serializable, Callable<Integer>

This is a class to precalculate keys.

It is disabled by default. Enable it by setting a caching file Name. To disable set the name to null.

See Also:
  • Field Details

  • Method Details

    • getPrecomputedAsymmetricKey

      public static AsymmetricKey getPrecomputedAsymmetricKey(AlgorithmParameter parameters)

      retrieves a precomputed key from the cache.

      Parameters:
      parameters - the parameters reflecting the requested key
      Returns:
      the requested key
    • setNumThreads

      public static int setNumThreads(int newNumThreads)

      Set the maximum number of working threads for the cache pre-calculator.

      Parameters:
      newNumThreads - the number of threads used for pre-calculation
      Returns:
      the previously set number of threads
    • getNumThreads

      public static int getNumThreads()

      Get the number of maximum threads used for cache pre-calculation.

      Returns:
      the currently set number of threads
    • getCacheFileName

      public static String getCacheFileName()

      Gets the currently set filename for key pre-calculation.

      Returns:
      the currently set filename
    • setCacheFileName

      public static String setCacheFileName(String name)

      Set name of cache file.

      If set to null the pre-calculator is disabled.

      Parameters:
      name - file name of the cache file
      Returns:
      String representing the previously set name
      Throws:
      IllegalThreadStateException - if the previous thread has not yet shutdown but a new thread was tried to be started
    • fillCache

      public static void fillCache()

      Commandline handler to pre-populate the key cache.

    • call

      public Integer call() throws IOException
      Specified by:
      call in interface Callable<Integer>
      Throws:
      IOException
    • setCacheSize

      public void setCacheSize() throws IOException

      Command line helper to set the maximum cache size of a cached item.

      Throws:
      IOException - if the specified file is not fond or there was an error when reading
    • setCacheSize

      public void setCacheSize(int index, int size) throws IOException

      Set the maximum cache size of a cached item.

      Parameters:
      index - the index of the cached item
      size - the size to be set
      Throws:
      IOException - if the specified file is not fond or there was an error when reading
    • removeCacheElement

      public void removeCacheElement() throws IOException

      Command line helper to remove a cached item type from the cache.

      Throws:
      IOException - if the specified file is not fond or there was an error when reading
    • removeCacheElement

      public void removeCacheElement(int index) throws IOException

      Remove a the specified item type from the cache.

      Parameters:
      index - the index of the element to be removed
      Throws:
      IOException - if the specified file is not fond or there was an error when reading
    • listCache

      public void listCache() throws IOException

      Command line helper to list cached items.

      Throws:
      IOException - if the specified file is not fond or there was an error when reading