de.flexiprovider.api
Class Registry

java.lang.Object
  |
  +--de.flexiprovider.api.Registry
Direct Known Subclasses:
CoreRegistry, ECRegistry, NFRegistry, PQCRegistry

public abstract class Registry
extends java.lang.Object

This class is responsible for the registration and instantiation of all cryptographic algorithms of the FlexiProvider. It provides methods for adding registrations of algorithms and methods for instantiating registered algorithms.

Author:
Johannes Müller, Martin Döring

Field Summary
static int ALG_PARAM_GENERATOR
          Constant for algorithm parameter generators
static int ALG_PARAM_SPEC
          Constant for algorithm parameter specifications
static int ALG_PARAMS
          Constant for algorithm parameters (used to encode and decode parameter specifications)
static int ASYMMETRIC_BLOCK_CIPHER
          Constant for asymmetric block ciphers
static int ASYMMETRIC_HYBRID_CIPHER
          Constant for asymmetric hybrid ciphers
static int BLOCK_CIPHER
          Constant for symmetric block ciphers
static int CIPHER
          Constant for generic ciphers
static int KEY_AGREEMENT
          Constant for key agreements
static int KEY_DERIVATION
          Constant for key derivations
static int KEY_FACTORY
          Constant for key factories
static int KEY_PAIR_GENERATOR
          Constant for key pair generators
static int MAC
          Constant for message authentication codes (MACs)
static int MESSAGE_DIGEST
          Constant for message digests (hash functions)
static int MODE
          Constant for modes of operation
static int PADDING_SCHEME
          Constant for padding schemes
static int SECRET_KEY_FACTORY
          Constant for secret key factories
static int SECRET_KEY_GENERATOR
          Constant for secret key generators
static int SECURE_RANDOM
          Constant for PRNGs
static int SIGNATURE
          Constant for digital signatures
 
Constructor Summary
Registry()
           
 
Method Summary
(package private) static void ()
           
static void add(int type, java.lang.Class algClass, java.lang.String algName)
          Register an algorithm of the given type under the given name.
static void add(int type, java.lang.Class algClass, java.lang.String[] algNames)
          Register an algorithm of the given type under the given names.
static void addStandardAlgParams(java.lang.String[] algNames, java.lang.String[] paramNames)
          Register a list of standardized algorithm parameters for the given list of algorithms.
static void addStandardAlgParams(java.lang.String algName, java.lang.String[] paramNames)
          Register a list of (names of) standardized algorithm parameters for the given algorithm.
static java.util.Enumeration getAlgorithms(int type)
          Return all algorithms of the given type.
static AlgorithmParameterGenerator getAlgParamGenerator(java.lang.String algName)
          Return an instance of the specified algorithm parameter generator.
static AlgorithmParameters getAlgParams(java.lang.String algName)
          Return an instance of the specified algorithm parameters.
static AlgorithmParameterSpec getAlgParamSpec(java.lang.String paramName)
          Return an instance of the algorithm parameter specification class corresponding to the given algorithm name.
static java.lang.Class getAlgParamSpecClass(java.lang.String algName)
          Return the algorithm parameter specification class corresponding to the given algorithm name.
static AsymmetricBlockCipher getAsymmetricBlockCipher(java.lang.String algName)
          Return an instance of the specified asymmetric block cipher.
static AsymmetricHybridCipher getAsymmetricHybridCipher(java.lang.String algName)
          Return an instance of the specified asymmetric hybrid cipher.
static BlockCipher getBlockCipher(java.lang.String transformation)
          Try to find an algorithm with the specified name inside the corresponding hashtable and return an instance of the algorithm.
static Cipher getCipher(java.lang.String algName)
          Return an instance of the specified cipher.
static KeyAgreement getKeyAgreement(java.lang.String algName)
          Return an instance of the specified key agreement scheme.
static KeyDerivation getKeyDerivation(java.lang.String algName)
          Return an instance of the specified key derivation function.
static KeyFactory getKeyFactory(java.lang.String algName)
          Return an instance of the specified key factory.
static KeyPairGenerator getKeyPairGenerator(java.lang.String algName)
          Return an instance of the specified key pair generator.
static Mac getMAC(java.lang.String algName)
          Return an instance of the specified message authentication code (MAC).
static MessageDigest getMessageDigest(java.lang.String algName)
          Return an instance of the specified message digest.
protected static Mode getMode()
           
protected static Mode getMode(java.lang.String modeName)
          Return an instance of the specified mode.
static java.util.Vector getNames(int type, java.lang.String name)
          Return all names of the given algorithm and type.
protected static PaddingScheme getPaddingScheme()
           
protected static PaddingScheme getPaddingScheme(java.lang.String paddingName)
          Return an instance of the specified padding scheme.
static SecretKeyFactory getSecretKeyFactory(java.lang.String algName)
          Return an instance of the specified secret key factory.
static SecretKeyGenerator getSecretKeyGenerator(java.lang.String algName)
          Return an instance of the specified secret key generator.
static SecureRandom getSecureRandom()
           
static SecureRandom getSecureRandom(java.lang.String algName)
          Return an instance of the specified source of randomness.
static Signature getSignature(java.lang.String algName)
          Return an instance of the specified signature.
static java.util.Vector getStandardAlgParams(java.lang.String algName)
          Return the set of standardized algorithm parameters registered for the given algorithm, or null if no parameters are registered for the given algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASYMMETRIC_BLOCK_CIPHER

public static final int ASYMMETRIC_BLOCK_CIPHER
Constant for asymmetric block ciphers

ASYMMETRIC_HYBRID_CIPHER

public static final int ASYMMETRIC_HYBRID_CIPHER
Constant for asymmetric hybrid ciphers

BLOCK_CIPHER

public static final int BLOCK_CIPHER
Constant for symmetric block ciphers

MODE

public static final int MODE
Constant for modes of operation

PADDING_SCHEME

public static final int PADDING_SCHEME
Constant for padding schemes

CIPHER

public static final int CIPHER
Constant for generic ciphers

MAC

public static final int MAC
Constant for message authentication codes (MACs)

MESSAGE_DIGEST

public static final int MESSAGE_DIGEST
Constant for message digests (hash functions)

SECURE_RANDOM

public static final int SECURE_RANDOM
Constant for PRNGs

SIGNATURE

public static final int SIGNATURE
Constant for digital signatures

ALG_PARAM_SPEC

public static final int ALG_PARAM_SPEC
Constant for algorithm parameter specifications

ALG_PARAMS

public static final int ALG_PARAMS
Constant for algorithm parameters (used to encode and decode parameter specifications)

ALG_PARAM_GENERATOR

public static final int ALG_PARAM_GENERATOR
Constant for algorithm parameter generators

SECRET_KEY_GENERATOR

public static final int SECRET_KEY_GENERATOR
Constant for secret key generators

KEY_PAIR_GENERATOR

public static final int KEY_PAIR_GENERATOR
Constant for key pair generators

SECRET_KEY_FACTORY

public static final int SECRET_KEY_FACTORY
Constant for secret key factories

KEY_FACTORY

public static final int KEY_FACTORY
Constant for key factories

KEY_DERIVATION

public static final int KEY_DERIVATION
Constant for key derivations

KEY_AGREEMENT

public static final int KEY_AGREEMENT
Constant for key agreements
Constructor Detail

Registry

public Registry()
Method Detail

static void ()

add

public static final void add(int type,
                             java.lang.Class algClass,
                             java.lang.String algName)
Register an algorithm of the given type under the given name.
Parameters:
type - the algorithm type
algClass - the class implementing the algorithm
algName - the name for the algorithm
Throws:
RegistrationException - if the expected and actual algorithm types do not match or an algorithm is already registered under the given name.

add

public static final void add(int type,
                             java.lang.Class algClass,
                             java.lang.String[] algNames)
Register an algorithm of the given type under the given names.
Parameters:
type - the algorithm type
algClass - the class implementing the algorithm
algNames - the names for the algorithm
Throws:
RegistrationException - if the expected and actual algorithm types do not match or an algorithm is already registered under one of the given names.

getAlgorithms

public static final java.util.Enumeration getAlgorithms(int type)
Return all algorithms of the given type.
Parameters:
type - the algorithm type
Returns:
an Enumeration of all algorithms contained in the hash table

getNames

public static final java.util.Vector getNames(int type,
                                              java.lang.String name)
Return all names of the given algorithm and type.
Parameters:
type - the algorithm type
name - (one of the) names of the algorithm
Returns:
a Vector containing all names of the algorithm

getAsymmetricBlockCipher

public static final AsymmetricBlockCipher getAsymmetricBlockCipher(java.lang.String algName)
                                                            throws NoSuchAlgorithmException
Return an instance of the specified asymmetric block cipher.
Parameters:
algName - the name of the asymmetric block cipher
Returns:
a new AsymmetricBlockCipher object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the asymmetric block cipher cannot be found.

getAsymmetricHybridCipher

public static final AsymmetricHybridCipher getAsymmetricHybridCipher(java.lang.String algName)
                                                              throws NoSuchAlgorithmException
Return an instance of the specified asymmetric hybrid cipher.
Parameters:
algName - the name of the asymmetric hybrid cipher
Returns:
a new AsymmetricHybridCipher object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the asymmetric hybrid cipher cannot be found.

getBlockCipher

public static final BlockCipher getBlockCipher(java.lang.String transformation)
                                        throws NoSuchAlgorithmException,
                                               NoSuchPaddingException
Try to find an algorithm with the specified name inside the corresponding hashtable and return an instance of the algorithm.
Parameters:
transformation - the transformation (either of the form 'algorithm' or 'algorithm/mode/padding')
Returns:
block cipher object
Throws:
NoSuchAlgorithmException - if the block cipher or mode cannot be found.
NoSuchPaddingException - if the padding scheme cannot be found.

getMode

protected static final Mode getMode()
Returns:
an instance of the default mode (CBC)

getMode

protected static final Mode getMode(java.lang.String modeName)
                             throws NoSuchModeException
Return an instance of the specified mode.
Parameters:
modeName - the name of the mode
Returns:
a new Mode object implementing the chosen algorithm
Throws:
NoSuchModeException - if the mode cannot be found.

getPaddingScheme

protected static final PaddingScheme getPaddingScheme()
Returns:
an instance of the default padding scheme (PKCS5Padding)

getPaddingScheme

protected static final PaddingScheme getPaddingScheme(java.lang.String paddingName)
                                               throws NoSuchPaddingException
Return an instance of the specified padding scheme.
Parameters:
paddingName - the name of the padding scheme
Returns:
a new PaddingScheme object implementing the chosen algorithm
Throws:
NoSuchPaddingException - if the padding scheme cannot be found.

getCipher

public static final Cipher getCipher(java.lang.String algName)
                              throws NoSuchAlgorithmException
Return an instance of the specified cipher.
Parameters:
algName - the name of the cipher
Returns:
a new Cipher object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the cipher cannot be found.

getMAC

public static final Mac getMAC(java.lang.String algName)
                        throws NoSuchAlgorithmException
Return an instance of the specified message authentication code (MAC).
Parameters:
algName - the name of the MAC
Returns:
a new Mac object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the MAC cannot be found.

getMessageDigest

public static final MessageDigest getMessageDigest(java.lang.String algName)
                                            throws NoSuchAlgorithmException
Return an instance of the specified message digest.
Parameters:
algName - the name of the message digest
Returns:
a new MessageDigest object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the message digest cannot be found.

getSecureRandom

public static final SecureRandom getSecureRandom(java.lang.String algName)
                                          throws NoSuchAlgorithmException
Return an instance of the specified source of randomness.
Parameters:
algName - the name of the source of randomness
Returns:
a new SecureRandom object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the source of randomness cannot be found.

getSecureRandom

public static final SecureRandom getSecureRandom()
Returns:
the default secure random
Throws:
java.lang.RuntimeException - if the default secure random cannot be instantiated.

getSignature

public static final Signature getSignature(java.lang.String algName)
                                    throws NoSuchAlgorithmException
Return an instance of the specified signature.
Parameters:
algName - the name of the signature
Returns:
a new Signature object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the signature cannot be found.

getAlgParamSpecClass

public static final java.lang.Class getAlgParamSpecClass(java.lang.String algName)
                                                  throws NoSuchAlgorithmException
Return the algorithm parameter specification class corresponding to the given algorithm name.
Parameters:
algName - the algorithm name
Returns:
the corresponding algorithm parameter specification class
Throws:
NoSuchAlgorithmException - if the parameters class cannot be found.

getAlgParamSpec

public static final AlgorithmParameterSpec getAlgParamSpec(java.lang.String paramName)
                                                    throws InvalidAlgorithmParameterException
Return an instance of the algorithm parameter specification class corresponding to the given algorithm name.
Parameters:
paramName - the name of the standard algorithm parameters
Returns:
the standard algorithm parameters
Throws:
InvalidAlgorithmParameterException - if the parameters cannot be found.

addStandardAlgParams

public static final void addStandardAlgParams(java.lang.String algName,
                                              java.lang.String[] paramNames)
Register a list of (names of) standardized algorithm parameters for the given algorithm. Additionally, each parameter set has to be registered separately using the add(int, Class, String) or add(int, Class, String[]) method with the ALG_PARAM_SPEC type.
Parameters:
algName - the name of the algorithm
paramNames - the names of the standardized algorithm parameters suitable for the specified algorithm

addStandardAlgParams

public static final void addStandardAlgParams(java.lang.String[] algNames,
                                              java.lang.String[] paramNames)
Register a list of standardized algorithm parameters for the given list of algorithms. Additionally, each parameter set has to be registered separately using the add(int, Class, String) or add(int, Class, String[]) method with the ALG_PARAM_SPEC type.
Parameters:
algNames - the names of the algorithms
paramNames - the names of the standardized algorithm parameters suitable for the specified algorithm

getStandardAlgParams

public static final java.util.Vector getStandardAlgParams(java.lang.String algName)
Return the set of standardized algorithm parameters registered for the given algorithm, or null if no parameters are registered for the given algorithm.
Parameters:
algName - the algorithm name
Returns:
the Vector of standardized algorithms parameters for the specified algorithm, or null if no parameters are registered for the algorithm

getAlgParams

public static final AlgorithmParameters getAlgParams(java.lang.String algName)
                                              throws NoSuchAlgorithmException
Return an instance of the specified algorithm parameters.
Parameters:
algName - the name of the algorithm parameters
Returns:
a new AlgorithmParameters object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the algorithm parameters cannot be found.

getAlgParamGenerator

public static final AlgorithmParameterGenerator getAlgParamGenerator(java.lang.String algName)
                                                              throws NoSuchAlgorithmException
Return an instance of the specified algorithm parameter generator.
Parameters:
algName - the name of the algorithm parameter generator
Returns:
a new AlgorithmParameterGenerator object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the algorithm parameter generator cannot be found.

getSecretKeyGenerator

public static final SecretKeyGenerator getSecretKeyGenerator(java.lang.String algName)
                                                      throws NoSuchAlgorithmException
Return an instance of the specified secret key generator.
Parameters:
algName - the name of the secret key generator
Returns:
a new SecretKeyGenerator object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the secret key generator cannot be found.

getKeyPairGenerator

public static final KeyPairGenerator getKeyPairGenerator(java.lang.String algName)
                                                  throws NoSuchAlgorithmException
Return an instance of the specified key pair generator.
Parameters:
algName - the name of the key pair generator
Returns:
a new KeyPairGenerator object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the key pair generator cannot be found.

getSecretKeyFactory

public static final SecretKeyFactory getSecretKeyFactory(java.lang.String algName)
                                                  throws NoSuchAlgorithmException
Return an instance of the specified secret key factory.
Parameters:
algName - the name of the secret key factory
Returns:
a new SecretKeyFactory object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the secret key factory cannot be found.

getKeyFactory

public static final KeyFactory getKeyFactory(java.lang.String algName)
                                      throws NoSuchAlgorithmException
Return an instance of the specified key factory.
Parameters:
algName - the name of the key factory
Returns:
a new KeyFactory object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the key factory cannot be found.

getKeyDerivation

public static final KeyDerivation getKeyDerivation(java.lang.String algName)
                                            throws NoSuchAlgorithmException
Return an instance of the specified key derivation function.
Parameters:
algName - the name of the key derivation function
Returns:
a new KeyDerivation object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the key derivation cannot be found.

getKeyAgreement

public static final KeyAgreement getKeyAgreement(java.lang.String algName)
                                          throws NoSuchAlgorithmException
Return an instance of the specified key agreement scheme.
Parameters:
algName - the name of the key agreement scheme
Returns:
a new KeyAgreement object implementing the chosen algorithm
Throws:
NoSuchAlgorithmException - if the key agreement scheme cannot be found.