public class IaikSecurity
extends java.lang.Object
getImplementation
method
is called for searching for a provider specific implementation of the requested
cryptographic object. If, for instance, a DES cipher implementation of the IAIK
provider would be requested the following program sequence will be performed:
IaikSecurity iaik = new IaikSecurity("DES", "Cipher", "IAIK"); CipherSpi cipher_spi = (CipherSpi)iaik.getImplementation();
Constructor and Description |
---|
IaikSecurity(java.lang.String algorithm,
java.lang.String type,
java.security.Provider provider)
Creates an IaikSecurity object to search for a algorithm
of the given type, implemented by the given provider.
|
IaikSecurity(java.lang.String algorithm,
java.lang.String type,
java.lang.String provider)
Creates an IaikSecurity object to search for a algorithm
of the given type, implemented by the given provider.
|
Modifier and Type | Method and Description |
---|---|
static java.security.AlgorithmParameterGenerator |
getAlgorithmParameterGeneratorInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get an AlgorithmParameterGenerator instance for the requested algorithm from the given provider.
|
static java.security.AlgorithmParameters |
getAlgorithmParametersInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get an AlgorithmParameters instance for the requested algorithm from the given provider.
|
static java.security.cert.CertificateFactory |
getCertificateFactoryInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get a CertificateFactory instance for the requested algorithm from the given provider.
|
static javax.crypto.Cipher |
getCipher(java.lang.String algorithm)
Gets a Cipher instance for the requested algorithm from the IAIK provider.
|
static javax.crypto.Cipher |
getCipher(java.lang.String algorithm,
int mode,
java.security.Key key,
java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
Gets and inits a Cipher instance for the requested algorithm from the IAIK provider.
|
static javax.crypto.Cipher |
getCipher(java.lang.String algorithm,
int mode,
java.security.Key key,
java.security.AlgorithmParameters params,
java.security.SecureRandom random)
Gets and inits a Cipher instance for the requested algorithm from the IAIK provider.
|
static javax.crypto.Cipher |
getCipherInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get a Cipher instance for the requested algorithm (transformation) from the given provider.
|
static java.lang.Object |
getEngine(java.lang.String algorithm,
java.lang.String type,
java.lang.Class typeClass,
java.security.Provider provider)
Tries to get a JCA/JCE engine of given type for the given algorithm.
|
java.lang.Object |
getImplementation()
Tries to find an implemenation for a specific algorithm.
|
static javax.crypto.KeyAgreement |
getKeyAgreementInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get a KeyAgreement instance for the requested algorithm from the given provider.
|
static java.security.KeyFactory |
getKeyFactoryInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get a KeyFactory instance for the requested algorithm from the given provider.
|
static javax.crypto.KeyGenerator |
getKeyGeneratorInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get a KeyGenerator instance for the requested algorithm from the given provider.
|
static java.security.KeyPairGenerator |
getKeyPairGeneratorInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get a KeyPairGenerator instance for the requested algorithm from the given provider.
|
static java.security.KeyStore |
getKeyStoreInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get a KeyStore instance for the requested algorithm from the given provider.
|
static javax.crypto.Mac |
getMacInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get a Mac instance for the requested algorithm from the given provider.
|
static MaskGenerationAlgorithm |
getMaskGenerationAlgorithmInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get a MaskGenerationAlgorithm instance for the requested algorithm from the given provider.
|
static java.security.MessageDigest |
getMessageDigestInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get a MessageDigest instance for the requested algorithm from the given provider.
|
java.security.Provider |
getProvider()
Returns the provider implementing the actual algorithm
|
static javax.crypto.SecretKeyFactory |
getSecretKeyFactoryInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get a SecretKeyFactory instance for the requested algorithm from the given provider.
|
static java.security.Signature |
getSignatureInstance(java.lang.String algorithm,
java.security.Provider provider)
Tries to get a Signature instance for the requested algorithm from the given provider.
|
static boolean |
getTryIAIKProviderFirst()
Decides whether to try the IAIK provider as first provider
anytime where applicable when internally instantiating a JCA Engine.
|
static void |
setTryIAIKProviderFirst(boolean tryIAIK)
Decides whether to try the IAIK provider as first provider
anytime where applicable when internally instantiating a JCA Engine.
|
public IaikSecurity(java.lang.String algorithm, java.lang.String type, java.lang.String provider)
algorithm
- the name of the algorithm (or an alias)type
- the type of the algorithm e.g. Cipherprovider
- the desired provider or null if any provider is appropriatepublic IaikSecurity(java.lang.String algorithm, java.lang.String type, java.security.Provider provider)
algorithm
- the name of the algorithm (or an alias)type
- the type of the algorithm e.g. Cipherprovider
- the desired provider or null if any provider is appropriatepublic static boolean getTryIAIKProviderFirst()
If the IAIK provider is installed as first provider within
the JCA Security framework any <Engine>.getInstance()
call automatically will try the IAIK provider as first provider.
However, if the IAIK provider is not installed within the
JCA Security framework it may be tried as first provider
as well (in front of any installed provider) by calling
a proper <Engine>.getInstance(Provider provider)
method. This method tells whether the IAIK
provider shall be tried as first or if relying on the providers
that are installed within the JCA Security framework.
true
if trying the IAIK provider
as first, false
if using the
providers installed in the JCA Security
framework (which, of course, may contain
the IAIK provider)public static void setTryIAIKProviderFirst(boolean tryIAIK)
If the IAIK provider is installed as first provider within
the JCA Security framework any <Engine>.getInstance()
call automatically will try the IAIK provider as first provider.
However, if the IAIK provider is not installed within the
JCA Security framework it may be tried as first provider
as well (in front of any installed provider) by calling
a proper <Engine>.getInstance(Provider provider)
method. This method maybe used to decide whether the IAIK
provider shall be tried as first or if relying on the providers
that are installed within the JCA Security framework.
tryIAIK
- true
(default) if trying the IAIK provider
as first, false
if using the
providers installed in the JCA Security
framework (which, of course, may contain
the IAIK provider)public static java.lang.Object getEngine(java.lang.String algorithm, java.lang.String type, java.lang.Class typeClass, java.security.Provider provider) throws java.lang.NoSuchMethodException, java.security.NoSuchAlgorithmException
algorithm
- the algorithm (e.g. "SHA1", "AES/CBC/PKCS5Padding",..)type
- the engine type (e.g. "SecretKeyFactory", "Cipher",...)typeClass
- the engine class (e.g. java.security.SecretKeyFactory.class, javax.crypto.cipher.Cipher.class,...)provider
- the Provider from which to get the enginejava.lang.NoSuchMethodException
- if Provider object based engine instantiation is not supported
for the requested engine type by the underlying Java VM (e.g. if
method SecretKeyFactory.getInstance(String algorithm, Provider provider)
is not supportedjava.security.NoSuchAlgorithmException
- if the requested algorithm is not supported by the given Providerpublic static java.security.AlgorithmParameters getAlgorithmParametersInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE AlgorithmParameters engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method AlgorithmParameters.getInstance(algorithm,provider)
is not available method AlgorithmParameters.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
an AlgorithmParameters implementation of
the first installed Provider that implements this algorithm id is returned
(AlgorithmParameters.getInstance(algorithm)
.
algorithm
- the requested algorithm nameprovider
- the provider from which to get an AlgorithmParameters engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no AlgorithmParameters implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static java.security.AlgorithmParameterGenerator getAlgorithmParameterGeneratorInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE AlgorithmParameterGenerator engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method AlgorithmParameterGenerator.getInstance(algorithm,provider)
is not available method AlgorithmParameterGenerator.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
an AlgorithmParameterGenerator implementation of
the first installed Provider that implements this algorithm id is returned
(AlgorithmParameterGenerator.getInstance(algorithm)
.
algorithm
- the requested algorithm nameprovider
- the provider from which to get an AlgorithmParameterGenerator engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no AlgorithmParameterGenerator implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static java.security.cert.CertificateFactory getCertificateFactoryInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE CertificateFactory engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method CertificateFactory.getInstance(algorithm,provider)
is not available method CertificateFactory.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
a CertificateFactory implementation of
the first installed Provider that implements this algorithm id is returned
(CertificateFactory.getInstance(algorithm)
.
algorithm
- the requested algorithm nameprovider
- the provider from which to get a CertificateFactory engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no CertificateFactory implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static javax.crypto.Cipher getCipherInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE Cipher engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method Cipher.getInstance(algorithm,provider)
is not available method Cipher.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
a Cipher implementation of
the first installed Provider that implements this algorithm id is returned
(Cipher.getInstance(algorithm)
.
algorithm
- the requested algorithm (transformation)provider
- the provider from which to get a Cipher engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no Cipher implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static javax.crypto.KeyAgreement getKeyAgreementInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE KeyAgreement engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method KeyAgreement.getInstance(algorithm,provider)
is not available method KeyAgreement.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
a KeyAgreement implementation of
the first installed Provider that implements this algorithm id is returned
(KeyAgreement.getInstance(algorithm)
.
algorithm
- the requested algorithm nameprovider
- the provider from which to get a KeyAgreement engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no KeyAgreement implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static javax.crypto.KeyGenerator getKeyGeneratorInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE KeyGenerator engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method KeyGenerator.getInstance(algorithm,provider)
is not available method KeyGenerator.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
a KeyGenerator implementation of
the first installed Provider that implements this algorithm id is returned
(KeyGenerator.getInstance(algorithm)
.
algorithm
- the requested algorithm nameprovider
- the provider from which to get a KeyGenerator engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no KeyGenerator implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static java.security.KeyFactory getKeyFactoryInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE KeyFactory engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method KeyFactory.getInstance(algorithm,provider)
is not available method KeyFactory.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
a KeyFactory implementation of
the first installed Provider that implements this algorithm id is returned
(KeyFactory.getInstance(algorithm)
.
algorithm
- the requested algorithm nameprovider
- the provider from which to get a KeyFactory engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no KeyFactory implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static java.security.KeyPairGenerator getKeyPairGeneratorInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE KeyPairGenerator engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method KeyPairGenerator.getInstance(algorithm,provider)
is not available method KeyPairGenerator.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
a KeyPairGenerator implementation of
the first installed Provider that implements this algorithm id is returned
(KeyPairGenerator.getInstance(algorithm)
.
algorithm
- the requested algorithm nameprovider
- the provider from which to get a KeyPairGenerator engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no KeyPairGenerator implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static java.security.KeyStore getKeyStoreInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE KeyStore engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method KeyStore.getInstance(algorithm,provider)
is not available method KeyStore.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
a KeyStore implementation of
the first installed Provider that implements this algorithm id is returned
(KeyStore.getInstance(algorithm)
.
algorithm
- the requested algorithm nameprovider
- the provider from which to get a KeyStore engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no KeyStore implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static javax.crypto.Mac getMacInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE Mac engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method Mac.getInstance(algorithm,provider)
is not available method Mac.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
a Mac implementation of
the first installed Provider that implements this algorithm id is returned
(Mac.getInstance(algorithm)
.
algorithm
- the requested algorithm nameprovider
- the provider from which to get a Mac engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no Mac implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static MaskGenerationAlgorithm getMaskGenerationAlgorithmInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE MaskGenerationAlgorithm engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method MaskGenerationAlgorithm.getInstance(algorithm,provider)
is not available method MaskGenerationAlgorithm.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
a MaskGenerationAlgorithm implementation of
the first installed Provider that implements this algorithm id is returned
(MaskGenerationAlgorithm.getInstance(algorithm)
.
algorithm
- the requested algorithm nameprovider
- the provider from which to get a MaskGenerationAlgorithm engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no MaskGenerationAlgorithm implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static java.security.MessageDigest getMessageDigestInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE MessageDigest engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method MessageDigest.getInstance(algorithm,provider)
is not available method MessageDigest.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
a MessageDigest implementation of
the first installed Provider that implements this algorithm id is returned
(MessageDigest.getInstance(algorithm)
.
algorithm
- the requested algorithm nameprovider
- the provider from which to get a MessageDigest engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no MessageDigest implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static javax.crypto.SecretKeyFactory getSecretKeyFactoryInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE SecretKeyFactory engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method SecretKeyFactory.getInstance(algorithm,provider)
is not available method SecretKeyFactory.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
a SecretKeyFactory implementation of
the first installed Provider that implements this algorithm id is returned
(SecretKeyFactory.getInstance(algorithm)
.
algorithm
- the requested algorithm nameprovider
- the provider from which to get a SecretKeyFactory engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no SecretKeyFactory implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static java.security.Signature getSignatureInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
If Provider object based JCA/JCE Signature engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method Signature.getInstance(algorithm,provider)
is not available method Signature.getInstance(algorithm,provider.getName())
is tried.
If null
is given as provider
a Signature implementation of
the first installed Provider that implements this algorithm id is returned
(Signature.getInstance(algorithm)
.
algorithm
- the requested algorithm nameprovider
- the provider from which to get a Signature engine for the requested algorithmjava.security.NoSuchAlgorithmException
- if there is no Signature implementation available for the requested algorithm
from the given provider (or from any installed provider if provider
is null
)public static javax.crypto.Cipher getCipher(java.lang.String algorithm) throws javax.crypto.NoSuchPaddingException, java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException
This method may be called instead of Cipher.getInstance
to
create a Cipher from the IAIK provider. When using the signed unltd
iaik_jce_(full).jar
calling getCipher
allows
unlimited strength cryptography also when the default jursidiction policy
files are installed (see IAIK-JCE installation guidelines for more
information).
algorithm
- the Cipher algorithm (transformation)java.security.NoSuchProviderException
- if the IAIK provider has not been installedjava.security.NoSuchAlgorithmException
- if no implementation for the requested cipher
algorithm is availablejavax.crypto.NoSuchPaddingException
- if the requested padding scheme is not availablepublic static javax.crypto.Cipher getCipher(java.lang.String algorithm, int mode, java.security.Key key, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random) throws javax.crypto.NoSuchPaddingException, java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
This method may be called instead of Cipher.getInstance
to
create a Cipher from the IAIK provider. When using the signed unltd
iaik_jce_(full).jar
calling getCipher
allows
unlimited strength cryptography also when the default jursidiction policy
files are installed (see IAIK-JCE installation guidelines for more
information).
algorithm
- the Cipher algorithm (transformation)mode
- the Cipher mode to be used for initialization
(e.g. Cipher.ENCRYPT_MODE, Cipher.DECRYPT_MODE)key
- the key to be used for initialization; if not null
params
- any parameters to be used for initialization; if not null
random
- the SecureRandom to be used for initialization; if not null
java.security.NoSuchProviderException
- if the IAIK provider has not been installedjava.security.NoSuchAlgorithmException
- if no implementation for the requested cipher
algorithm is availablejavax.crypto.NoSuchPaddingException
- if no implementation for the given cipher
algorithm is availablejava.security.InvalidAlgorithmParameterException
- if the parameters are not appropriate
for the given Cipherjava.security.InvalidKeyException
- if the key is not appropriate for the given Cipherpublic static javax.crypto.Cipher getCipher(java.lang.String algorithm, int mode, java.security.Key key, java.security.AlgorithmParameters params, java.security.SecureRandom random) throws javax.crypto.NoSuchPaddingException, java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
This method may be called instead of Cipher.getInstance
to
create a Cipher from the IAIK provider. When using the signed unltd
iaik_jce_(full).jar
calling getCipher
allows
unlimited strength cryptography also when the default jursidiction policy
files are installed (see IAIK-JCE installation guidelines for more
information).
algorithm
- the Cipher algorithm (transformation)mode
- the Cipher mode to be used for initialization
(e.g. Cipher.ENCRYPT_MODE, Cipher.DECRYPT_MODE)key
- the key to be used for initialization; if not null
params
- any parameters to be used for initialization; if not null
random
- the SecureRandom to be used for initialization; if not null
java.security.NoSuchProviderException
- if the IAIK provider has not been installedjava.security.NoSuchAlgorithmException
- if no implementation for the requested cipher
algorithm is availablejavax.crypto.NoSuchPaddingException
- if no implementation for the given cipher
algorithm is availablejava.security.InvalidAlgorithmParameterException
- if the parameters are not appropriate
for the given Cipherjava.security.InvalidKeyException
- if the key is not appropriate for the given Cipherpublic java.lang.Object getImplementation() throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException
java.security.NoSuchAlgorithmException
- if no provider implements the algorithmjava.security.NoSuchProviderException
- if the provider does not existpublic java.security.Provider getProvider()