iaik.asn1.structures
Class AlgorithmID

java.lang.Object
  |
  +--iaik.asn1.structures.AlgorithmID
Direct Known Subclasses:
AlgorithmIdentifier

public class AlgorithmID
extends java.lang.Object
implements ASN1Type

This class implements the ASN.1 type "AlgorithmIdentifier".

An AlgorithmID object unequivocally identifies some specific algorithm by assigning a particular ObjectID to it. An algorithmID optionally may include algorithm parameters:

 AlgorithmIdentifier  ::=  SEQUENCE  {
      algorithm               OBJECT IDENTIFIER,
      parameters              ANY DEFINED BY algorithm OPTIONAL  }
 
An AlgorithmID object may be, for instance, used for specifying the signature algorithm when signing a X509Certificate, e,g.:

 X509Certificate cert = new X509Certificate();
   ...
 cert.sign(AlgorithmID.md5WithRSAEncryption, issuerPrivateKey);
 

This class statically registers AlgortihmIDs for several public key, key exchange, symmetric, signature and message digest algorithms. AlgorithmIDs that are already statically registered by this class easily may be obtained by only calling their corresponding parameter names, e.g.:

 AlgorithmID algID = AlgorithmID.md5WithRSAEncryption;
 
AttentionThis static registration part of this class only associates one specific object identifier with a particular AlgorithmID. If you intend to use another OID than the registered one, you should call the AlgorithmID(String objectID, String name, String implementation) constructor for registering the OID as alternative OID for the specific algorithm, where objectID indicates the OID in mind, name specifies a name for the OID, and implementationName a string constant to be used for querying for an implementaion of the algorithm. This constant may be the specific algorithm´s standard name, a registered algorithm alias (but preferably not an OID alias!) (see IAIK provider), or a proper "transformation string" (e.g. "DES/CBC/PKCS5Padding") when dealing with a Cipher algorithm. After registration has been performed, the getSignatureInstance(), getMessageDigestInstance(), getCipherInstance(), getKeyAgreementInstance(), or the getInstance() method may be used to search for an implementation of the corresponding algorithm, whereas getInstance() steps through all the other algorithm types, e.g.:
 AlgorithmID algID = AlgorithmID.dsa;
 Signature dsa = algID.getSignatureInstance();
 //or:
 Signature dsa = (Signature)algID.getInstance();
 
Unfortunately sometimes there exist multiple object identifiers associated with the same algorithm. Where recognized, the IAIK provider) registers such object identifiers as aliases for the specific algorithm. Consider, for instance, the two OID strings "1.3.14.3.2.29" and "1.2.840.113549.1.1.5", both identifying the "sha1WithRSAEncryption" signature algorithm. Both OID strings are registered by the IAIK provider as aliases for the "SHA/RSA" algorithm. However the sha1WithRSAEncryption parameter of this class only associates the "1.3.14.3.2.29" object identifier with the "SHA/RSA" algorithm by statically calling
 public static AlgorithmID sha1WithRSAEncryption =
    new AlgorithmID("1.3.14.3.2.29", "sha1WithRSAEncryption", "SHA/RSA");
 
Now, if you prefer to use "1.2.840.113549.1.1.5" instead of "1.3.14.3.2.29" you additionally may register this OID by calling:
  AlgorithmID algID =
    new AlgorithmID("1.2.840.113549.1.1.5", "sha1WithRSAEncryption", "SHA/RSA");
 
Notice, that this will not discard the predefined AlgorithmID.sha1WithRSAEncryption. Accessing AlgorithmID.sha1WithRSAEncryption, again will show 1.3.14.3.2.29. However, you may access your new algorithmID with variable algID you have just created, and when parsing an algorithmID both OIDs will be recognized and handeld properly. Note that proper parsing for "SHA/RSA" with "1.2.840.113549.1.1.5" already is ensured by alias registration in the IAIK provider. However you may wish to create a new "SHA/RSA" AlgorithmID for "1.2.840.113549.1.1.5", or you may know of a object ID which already is not registered as alias). Or you may deal with a cipher where alias registration may not satisfy since padding scheme and cipher mode maybe required. The, for instance, des_CBC cipher algorithmID statically is registered by using the "DES/CBC/PKCS5Padding" transformation string as implementation name:
 public static AlgorithmID des_CBC =
    new AlgorithmID("1.3.14.3.2.7", "DES-CBC", "DES/CBC/PKCS5Padding");
 

For defining AlgorithmIDs for algorithms not implemented by the IAIK provider, this class uses the AlgorithmID(String objectID, String name) constructor.

If you want to change the object identifier of an already existing AlgorithmID permanently, you may use the changeObjectID(AlgorithmID algID, ObjectID oid) or changeOIDString(AlgorithmID algID, String oidString) method; the latter adopts any existing name or shortName from the old oid. With JDK 1.2 the SUN provider, for instance, has changed the algorithm oid of the DSA algorithm from 1.3.14.3.2.12 to 1.2.840.10040.4.1, whereas IAIK continues to use 1.3.14.3.2.12. An application wishing to use the new OID may allocate it by:

 AlgorithmID.changeOIDString(AlgorithmID.dsa, "1.2.840.10040.4.1");
 
or
 ObjectID oid = new ObjectID("1.2.840.10040.4.1", "DSA", "DSA");
 AlgorithmID.changeObjectID(AlgorithmID.dsa, oid);
 
Attention You should clone an algorithmID before adding parameters to avoid unintentional parameter allocation!

See Also:
ASN1Type, ASN1Object, ObjectID

Field Summary
static AlgorithmID cast5_CBC
          Creates an AlgorithmID for the CAST5 symmetric block cipher used in CBC mode.
static AlgorithmID des_CBC
          Creates an AlgorithmID for the DES symmetric block cipher used in CBC mode.
static AlgorithmID des_EDE3_CBC
          Creates an AlgorithmID for the Triple DES symmetric block cipher used in CBC mode.
static AlgorithmID dhKeyAgreement
          Creates an AlgorithmID for the Diffie-Hellman key exchange algorithm.
static AlgorithmID dsa
          Creates an AlgorithmID for the DSA signature algorithm.
static AlgorithmID dsaWithSHA
          Creates an AlgorithmID for the dsaWithSHA signature algorithm.
static AlgorithmID dsaWithSHA1
          Creates an AlgorithmID for the dsaWithSHA1 signature algorithm.
static AlgorithmID dsaX957
          Creates an AlgorithmID for the DSA signature algorithm, using the OID defined in the X.957 standard.
static AlgorithmID idea_CBC
          Creates an AlgorithmID for the IDEA symmetric block cipher used in CBC mode.
protected static java.util.Hashtable implementations
          Implementation repository.
static AlgorithmID md2
          Creates an AlgorithmID for the MD2 message digest algorithm.
static AlgorithmID md2WithRSAEncryption
          Creates an AlgorithmID for the md2WithRSAEncryption signature algorithm.
static AlgorithmID md4
          Creates an AlgorithmID for the MD4 message digest algorithm.
static AlgorithmID md4WithRSAEncryption
          Creates an AlgorithmID for the md4WithRSAEncryption signature algorithm.
static AlgorithmID md5
          Creates an AlgorithmID for the MD5 message digest algorithm.
static AlgorithmID md5WithRSAEncryption
          Creates an AlgorithmID for the md5WithRSAEncryption signature algorithm.
static AlgorithmID mgf1
          Creates an AlgorithmID for the MGF1 mask generation algorithm used in PKCS-1 v2.0.
static AlgorithmID pbeWithMD5AndDES_CBC
          Creates an AlgorithmID for the pbeWithMD5AndDES_CBC key-encryption algorithm as defined by PKCS#5.
static AlgorithmID pbeWithSHAAnd128BitRC2_CBC
          Creates an AlgorithmID for the pbeWithSHAAnd128BitRC2_CBC key-encryption algorithm as defined by PKCS#12.
static AlgorithmID pbeWithSHAAnd128BitRC4
          Creates an AlgorithmID for the pbeWithSHAAnd128BitRC4 key-encryption algorithm as defined by PKCS#12.
static AlgorithmID pbeWithSHAAnd2_KeyTripleDES_CBC
          Creates an AlgorithmID for the pbeWithSHAAnd2_KeyTripleDES_CBC key-encryption algorithm as defined by PKCS#12.
static AlgorithmID pbeWithSHAAnd3_KeyTripleDES_CBC
          Creates an AlgorithmID for the pbeWithSHAAnd3_KeyTripleDES_CBC key-encryption algorithm as defined by PKCS#12.
static AlgorithmID pbeWithSHAAnd40BitRC2_CBC
          Creates an AlgorithmID for the pbeWithSHAAnd40BitRC2_CBC key-encryption algorithm as defined by PKCS#12.
static AlgorithmID pbeWithSHAAnd40BitRC4
          Creates an AlgorithmID for the pbeWithSHAAnd40BitRC4 key-encryption algorithm as defined by PKCS#12.
static AlgorithmID rc2_CBC
          Creates an AlgorithmID for the RC2 symmetric block cipher used in CBC mode.
static AlgorithmID rc4
          Creates an AlgorithmID for the RC4 stream cipher.
static AlgorithmID rc5_CBC
          Creates an AlgorithmID for the RC5 symmetric block cipher used in CBC mode.
static AlgorithmID rsa
          Creates an AlgorithmID for the RSA public key algorithm.
static AlgorithmID rsaEncryption
          Creates an AlgorithmID for the RSA encryption signature algorithm.
static AlgorithmID rsaESOAEP
          Creates an AlgorithmID for the RSA encryption signature algorithm, using the OAEP encoding scheme defined in PKCS-1 v2.0 ObjectID = "1.2.840.113549.1.1.7" name = "rsaESOAEP" implementationName = "RSA-OAEP" For addressing it, use AlgorithmID.rsaESOAEP.
static AlgorithmID sha
          Creates an AlgorithmID for the SHA message digest algorithm.
static AlgorithmID sha1
          Creates an AlgorithmID for the SHA1 message digest algorithm which is the same as SHA.
static AlgorithmID sha1WithRSAEncryption
          Creates an AlgorithmID for the sha1WithRSAEncryption signature algorithm.
 
Constructor Summary
AlgorithmID()
          Default constructor.
AlgorithmID(ASN1Object algorithmID)
          Creates a new AlgorithmID from an ASN1Object.
AlgorithmID(DerInputStream is)
          Decodes an AlgorithmID from a DerInputStream.
AlgorithmID(ObjectID algorithm)
          Creates a new AlgorithmID from an ObjectID.
AlgorithmID(ObjectID algorithm, ASN1Object parameter)
          Creates a new AlgorithmID from an ObjectID and algorithm parameters.
AlgorithmID(java.lang.String objectID, java.lang.String name)
          Creates a new AlgorithmID from an object identifier and a name.
AlgorithmID(java.lang.String objectID, java.lang.String name, java.lang.String implementationName)
          Creates a new AlgorithmID from an object identifier, a name and an implementation.
 
Method Summary
static boolean changeObjectID(AlgorithmID algID, ObjectID oid)
          Changes the object identifier of the given AlgorithmID object.
static boolean changeOIDString(AlgorithmID algID, java.lang.String oidString)
          Changes the object identifier string of the given AlgorithmID object.
 java.lang.Object clone()
          Returns a clone of this AlgorithmID.
 void decode(ASN1Object algorithmID)
          Decodes an AlgorithmID from the given ASN1Object.
 boolean equals(java.lang.Object obj)
          Compares this AlgorithmID with the given AlgorithmID.
 ObjectID getAlgorithm()
          Returns the ObjectID of the algorithm.
 AlgorithmParameters getAlgorithmParameters(java.lang.String algorithm)
          Returns the parameters of the algorithm as java.security.AlgorithmParameters object.
 Cipher getCipherInstance()
          Tries to find a Cipher implementation for this AlgorithmIdentifier.
 java.lang.String getImplementationName()
          Returns the name for an implementation of this algorithm.
 java.lang.Object getInstance()
          Tries to find an implementation for this AlgorithmIdentifier.
 KeyAgreement getKeyAgreementInstance()
          Tries to find a KeyAgreement implementation for this AlgorithmIdentifier.
 KeyFactory getKeyFactoryInstance()
          Tries to find a KeyFactory implementation for this AlgorithmIdentifier.
 MessageDigest getMessageDigestInstance()
          Tries to find a MessageDigest implementation for this AlgorithmIdentifier.
 java.lang.String getName()
          Returns the name registered for this AlgorithmID or the object identifier string if there is no name registered.
 ASN1Object getParameter()
          Returns the parameters of the algorithm as ASN1Object.
 Signature getSignatureInstance()
          Tries to find a Signature implementation for this AlgorithmIdentifier.
 void setAlgorithmParameters(AlgorithmParameters parameters)
          Sets the parameters of the algorithm.
 void setParameter(ASN1Object parameters)
          Sets the parameters of the algorithm.
 ASN1Object toASN1Object()
          Returns the AlgorithmID as an (SEQUENCE) ASN1Object.
 java.lang.String toString()
          Returns a string that represents this AlgorithmIdentifier.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

implementations

protected static java.util.Hashtable implementations
Implementation repository.

dhKeyAgreement

public static AlgorithmID dhKeyAgreement
Creates an AlgorithmID for the Diffie-Hellman key exchange algorithm. For addressing it, use AlgorithmID.dhKeyAgreement.

rsaEncryption

public static AlgorithmID rsaEncryption
Creates an AlgorithmID for the RSA encryption signature algorithm. For addressing it, use AlgorithmID.rsaEncryption.

rsaESOAEP

public static AlgorithmID rsaESOAEP
Creates an AlgorithmID for the RSA encryption signature algorithm, using the OAEP encoding scheme defined in PKCS-1 v2.0 For addressing it, use AlgorithmID.rsaESOAEP.

mgf1

public static AlgorithmID mgf1
Creates an AlgorithmID for the MGF1 mask generation algorithm used in PKCS-1 v2.0. For addressing it, use AlgorithmID.mgf1.

md2WithRSAEncryption

public static AlgorithmID md2WithRSAEncryption
Creates an AlgorithmID for the md2WithRSAEncryption signature algorithm. For addressing it, use AlgorithmID.md2WithRSAEncryption.

md4WithRSAEncryption

public static AlgorithmID md4WithRSAEncryption
Creates an AlgorithmID for the md4WithRSAEncryption signature algorithm. For addressing it, use AlgorithmID.md4WithRSAEncryption.

md5WithRSAEncryption

public static AlgorithmID md5WithRSAEncryption
Creates an AlgorithmID for the md5WithRSAEncryption signature algorithm. For addressing it, use AlgorithmID.md5WithRSAEncryption.

sha1WithRSAEncryption

public static AlgorithmID sha1WithRSAEncryption
Creates an AlgorithmID for the sha1WithRSAEncryption signature algorithm. For addressing it, use AlgorithmID.sha1WithRSAEncryption.

dsa

public static AlgorithmID dsa
Creates an AlgorithmID for the DSA signature algorithm. For addressing it, use AlgorithmID.dsa.

dsaX957

public static AlgorithmID dsaX957
Creates an AlgorithmID for the DSA signature algorithm, using the OID defined in the X.957 standard. For addressing it, use AlgorithmID.dsaX957.

dsaWithSHA

public static AlgorithmID dsaWithSHA
Creates an AlgorithmID for the dsaWithSHA signature algorithm. For addressing it, use AlgorithmID.dsaWithSHA.

dsaWithSHA1

public static AlgorithmID dsaWithSHA1
Creates an AlgorithmID for the dsaWithSHA1 signature algorithm. For addressing it, use AlgorithmID.dsaWithSHA1.

pbeWithMD5AndDES_CBC

public static AlgorithmID pbeWithMD5AndDES_CBC
Creates an AlgorithmID for the pbeWithMD5AndDES_CBC key-encryption algorithm as defined by PKCS#5. For addressing it, use AlgorithmID.pbeWithMD5AndDES_CBC.

pbeWithSHAAnd128BitRC4

public static AlgorithmID pbeWithSHAAnd128BitRC4
Creates an AlgorithmID for the pbeWithSHAAnd128BitRC4 key-encryption algorithm as defined by PKCS#12. For addressing it, use AlgorithmID.pbeWithSHAAnd128BitRC4.

pbeWithSHAAnd40BitRC4

public static AlgorithmID pbeWithSHAAnd40BitRC4
Creates an AlgorithmID for the pbeWithSHAAnd40BitRC4 key-encryption algorithm as defined by PKCS#12. For addressing it, use AlgorithmID.pbeWithSHAAnd40BitRC4.

pbeWithSHAAnd3_KeyTripleDES_CBC

public static AlgorithmID pbeWithSHAAnd3_KeyTripleDES_CBC
Creates an AlgorithmID for the pbeWithSHAAnd3_KeyTripleDES_CBC key-encryption algorithm as defined by PKCS#12. For addressing it, use AlgorithmID.pbeWithSHAAnd3_KeyTripleDES_CBC.

pbeWithSHAAnd2_KeyTripleDES_CBC

public static AlgorithmID pbeWithSHAAnd2_KeyTripleDES_CBC
Creates an AlgorithmID for the pbeWithSHAAnd2_KeyTripleDES_CBC key-encryption algorithm as defined by PKCS#12. For addressing it, use AlgorithmID.pbeWithSHAAnd2_KeyTripleDES_CBC.

pbeWithSHAAnd128BitRC2_CBC

public static AlgorithmID pbeWithSHAAnd128BitRC2_CBC
Creates an AlgorithmID for the pbeWithSHAAnd128BitRC2_CBC key-encryption algorithm as defined by PKCS#12. For addressing it, use AlgorithmID.pbeWithSHAAnd128BitRC2_CBC.

pbeWithSHAAnd40BitRC2_CBC

public static AlgorithmID pbeWithSHAAnd40BitRC2_CBC
Creates an AlgorithmID for the pbeWithSHAAnd40BitRC2_CBC key-encryption algorithm as defined by PKCS#12. For addressing it, use AlgorithmID.pbeWithSHAAnd40BitRC2_CBC.

rsa

public static AlgorithmID rsa
Creates an AlgorithmID for the RSA public key algorithm. For addressing it, use AlgorithmID.rsa.

rc2_CBC

public static AlgorithmID rc2_CBC
Creates an AlgorithmID for the RC2 symmetric block cipher used in CBC mode. For addressing it, use AlgorithmID.rc2_CBC.

rc4

public static AlgorithmID rc4
Creates an AlgorithmID for the RC4 stream cipher. For addressing it, use AlgorithmID.rc4.

des_EDE3_CBC

public static AlgorithmID des_EDE3_CBC
Creates an AlgorithmID for the Triple DES symmetric block cipher used in CBC mode. For addressing it, use AlgorithmID.des_EDE3_CBC.

des_CBC

public static AlgorithmID des_CBC
Creates an AlgorithmID for the DES symmetric block cipher used in CBC mode. For addressing it, use AlgorithmID.des_CBC.

idea_CBC

public static AlgorithmID idea_CBC
Creates an AlgorithmID for the IDEA symmetric block cipher used in CBC mode. For addressing it, use AlgorithmID.des_CBC.

cast5_CBC

public static AlgorithmID cast5_CBC
Creates an AlgorithmID for the CAST5 symmetric block cipher used in CBC mode. For addressing it, use AlgorithmID.cast5_CBC.

rc5_CBC

public static AlgorithmID rc5_CBC
Creates an AlgorithmID for the RC5 symmetric block cipher used in CBC mode. For addressing it, use AlgorithmID.rc5_CBC.

md2

public static AlgorithmID md2
Creates an AlgorithmID for the MD2 message digest algorithm. For addressing it, use AlgorithmID.md2.

md4

public static AlgorithmID md4
Creates an AlgorithmID for the MD4 message digest algorithm. For addressing it, use AlgorithmID.md4.

md5

public static AlgorithmID md5
Creates an AlgorithmID for the MD5 message digest algorithm. For addressing it, use AlgorithmID.md5.

sha

public static AlgorithmID sha
Creates an AlgorithmID for the SHA message digest algorithm. For addressing it, use AlgorithmID.sha.

sha1

public static AlgorithmID sha1
Creates an AlgorithmID for the SHA1 message digest algorithm which is the same as SHA. For addressing it, use AlgorithmID.sha1.
Constructor Detail

AlgorithmID

public AlgorithmID()
Default constructor. Creates an AlgorithmID object with null ObjectID and null parameters.

AlgorithmID

public AlgorithmID(java.lang.String objectID,
                   java.lang.String name)
Creates a new AlgorithmID from an object identifier and a name. The AlgorithmID parameters are set to NULL.
Parameters:
objectID - the object identifier of the algorithm as a string; e.g. "2.5.8.1.1"
name - the name for this object identifier; e.g "rsa"

AlgorithmID

public AlgorithmID(java.lang.String objectID,
                   java.lang.String name,
                   java.lang.String implementationName)
Creates a new AlgorithmID from an object identifier, a name and an implementation. The AlgorithmID parameters are set to NULL.
Parameters:
objectID - the object identifier of the algorithm as a string; e.g. "1.2.840.113549.3.7"
name - the name for this object identifier; e.g "DES-EDE3-CBC"
implementationName - the internal implementation name; e.g. "3DES/CBC/PKCS5Padding"

AlgorithmID

public AlgorithmID(ObjectID algorithm)
Creates a new AlgorithmID from an ObjectID. The parameters are set to NULL.
Parameters:
algorithm - the ObjectID of the algorithm

AlgorithmID

public AlgorithmID(ObjectID algorithm,
                   ASN1Object parameter)
Creates a new AlgorithmID from an ObjectID and algorithm parameters.
Parameters:
algorithm - the ObjectID of the algorithm
parameter - the algorithm parameters

AlgorithmID

public AlgorithmID(ASN1Object algorithmID)
            throws CodingException
Creates a new AlgorithmID from an ASN1Object. The supplied ASN1Object represents an already existing AlgorithmID that may have been created by means of the toASN1Object() method.
Parameters:
algorithmID - the AlgorithmID as ASN1Object
Throws:
CodingException - if the ASN1Object is no AlgorithmID

AlgorithmID

public AlgorithmID(DerInputStream is)
            throws java.io.IOException
Decodes an AlgorithmID from a DerInputStream.

The given DerInputStream supplies DER encoded data that represents an already existing AlgorithmID.

Parameters:
is - the DerInputStream supplying the DER encoded ASN1Object
Throws:
java.io.IOException - if an I/O or decoding error occurs
Method Detail

changeObjectID

public static boolean changeObjectID(AlgorithmID algID,
                                     ObjectID oid)
Changes the object identifier of the given AlgorithmID object.

This method may be used to allocate a new object identifier to an already existing AlgorithmID. With JDK 1.2 the SUN provider, for instance, has changed the algorithm oid of the DSA algorithm from 1.3.14.3.2.12 to 1.2.840.10040.4.1, whereas IAIK continues to use 1.3.14.3.2.12. An application wishing to use the new OID, can allocate it by using this method, e.g.:

 ObjectID oid = new ObjectID("1.2.840.10040.4.1", "DSA");
 AlgorithmID.changeObjectID(AlgorithmID.dsa, oid);
 
If you only want to change the OID string, but keep name and shortName, you may use method changeOIDString(AlgorithmID algID, String oidString).
Parameters:
algID - the AlgorithmID to which a new OID shall be allocated
oid - the new object identifier
Returns:
true if the OID successfully has been changed, false otherwise

changeOIDString

public static boolean changeOIDString(AlgorithmID algID,
                                      java.lang.String oidString)
Changes the object identifier string of the given AlgorithmID object.

This method may be used to allocate a new object identifier to an already existing AlgorithmID. With JDK 1.2 the SUN provider, for instance, has changed the algorithm oid of the DSA algorithm from 1.3.14.3.2.12 to 1.2.840.10040.4.1, whereas IAIK continues to use 1.3.14.3.2.12. An application wishing to use the new OID, can allocate it by using this method, e.g.:

 AlgorithmID.changeOIDString(AlgorithmID.dsa, "1.2.840.10040.4.1");
 
This method adopts any registered name and shortName from the old object identifer; and only changes the OID string. To set an entire new object identifier, use method changeObjectID(AlgorithmID, ObjectID).
Parameters:
algID - the AlgorithmID to which a new OID shall be allocated
oid - the new object identifier
Returns:
true if the OID successfully has been changed, false otherwise

decode

public void decode(ASN1Object algorithmID)
            throws CodingException
Decodes an AlgorithmID from the given ASN1Object.

The supplied ASN1Object represents an already existing AlgorithmID that may have been created by means of the toASN1Object() method.

Specified by:
decode in interface ASN1Type
Parameters:
algorithmID - the AlgorithmID as ASN1Object
Throws:
CodingException - if the ASN1Object is no AlgorithmID

toASN1Object

public ASN1Object toASN1Object()
Returns the AlgorithmID as an (SEQUENCE) ASN1Object.
Specified by:
toASN1Object in interface ASN1Type
Returns:
the AlgorithmID as ASN1Object
See Also:
SEQUENCE

getImplementationName

public java.lang.String getImplementationName()
                                       throws NoSuchAlgorithmException
Returns the name for an implementation of this algorithm.
Returns:
the name for an implementation e.g. "DES/CBC"
Throws:
NoSuchAlgorithmException - if there is no name for the implementation

getInstance

public java.lang.Object getInstance()
                             throws NoSuchAlgorithmException
Tries to find an implementation for this AlgorithmIdentifier. This method calls the getInstance() methods in the following order:
Returns:
an instance of the object which implements this algorithm
Throws:
NoSuchAlgorithmException - if there is no implementation

getCipherInstance

public Cipher getCipherInstance()
                         throws NoSuchAlgorithmException
Tries to find a Cipher implementation for this AlgorithmIdentifier. This method calls Cipher.getInstance(algorithm) by substituting the algorithmID´s for the algorithm parameter in Cipher.getInstance(algorithm).
Returns:
an Cipher instance of the object which implements this algorithm
Throws:
NoSuchAlgorithmException - if there is no Cipher implementation

getSignatureInstance

public Signature getSignatureInstance()
                               throws NoSuchAlgorithmException
Tries to find a Signature implementation for this AlgorithmIdentifier. This method calls Signature.getInstance(algorithm) by substituting the algorithmID´s for the algorithm parameter in Signature.getInstance(algorithm).
Returns:
a Signature instance of the object which implements this algorithm
Throws:
NoSuchAlgorithmException - if there is no Signature implementation

getMessageDigestInstance

public MessageDigest getMessageDigestInstance()
                                       throws NoSuchAlgorithmException
Tries to find a MessageDigest implementation for this AlgorithmIdentifier. This method calls MessageDigest.getInstance(algorithm) by substituting the algorithmID´s for the algorithm parameter in MessageDigest.getInstance(algorithm).
Returns:
a MessageDigest instance of the object which implements this algorithm
Throws:
NoSuchAlgorithmException - if there is no MessageDigest implementation

getKeyAgreementInstance

public KeyAgreement getKeyAgreementInstance()
                                     throws NoSuchAlgorithmException
Tries to find a KeyAgreement implementation for this AlgorithmIdentifier. This method calls KeyAgreement.getInstance(algorithm) by substituting the algorithmID´s for the algorithm parameter in KeyAgreement.getInstance(algorithm).
Returns:
a KeyAgreement instance of the object which implements this algorithm
Throws:
NoSuchAlgorithmException - if there is no KeyAgreement implementation

getKeyFactoryInstance

public KeyFactory getKeyFactoryInstance()
                                 throws NoSuchAlgorithmException
Tries to find a KeyFactory implementation for this AlgorithmIdentifier. This method calls KeyFactory.getInstance(algorithm) by substituting the algorithmID´s for the algorithm parameter in KeyFactory.getInstance(algorithm).
Returns:
a KeyFactory instance of the object which implements this algorithm
Throws:
NoSuchAlgorithmException - if there is no KeyAgreement implementation

clone

public java.lang.Object clone()
Returns a clone of this AlgorithmID. Shall be used when setting an algorithm parameter to an already defined AlgorithmID (e.g. AlgorithmID.rsa).
Overrides:
clone in class java.lang.Object
Returns:
a clone of this AlgorithmID

getAlgorithm

public ObjectID getAlgorithm()
Returns the ObjectID of the algorithm.
Returns:
the ObjectID of the algorithm
See Also:
ObjectID

getParameter

public ASN1Object getParameter()
Returns the parameters of the algorithm as ASN1Object.
Returns:
the parameters of the algorithm

getAlgorithmParameters

public AlgorithmParameters getAlgorithmParameters(java.lang.String algorithm)
                                           throws NoSuchAlgorithmException
Returns the parameters of the algorithm as java.security.AlgorithmParameters object.
Parameters:
algorithm - the name of the algorithm the parameters belong to
Returns:
the parameter of the algorithm
Throws:
NoSuchAlgorithmException - if there are no parameters to return

setAlgorithmParameters

public void setAlgorithmParameters(AlgorithmParameters parameters)
Sets the parameters of the algorithm. The parameters have to be specified as java.security.AlgorithmParameters object.
Parameters:
parameters - the parameters of the algorithm

setParameter

public void setParameter(ASN1Object parameters)
Sets the parameters of the algorithm. The parameters have to be specified as ASN1Object.
Parameters:
parameters - the parameters of the algorithm

getName

public java.lang.String getName()
Returns the name registered for this AlgorithmID or the object identifier string if there is no name registered.
Returns:
the name of this AlgorithmID or the ObjectID string if no name is registered.

equals

public boolean equals(java.lang.Object obj)
Compares this AlgorithmID with the given AlgorithmID.
Overrides:
equals in class java.lang.Object
Parameters:
obj - the other AlgorithmID
Returns:
true, if the two AlgorithmIDs are equal, false otherwise

toString

public java.lang.String toString()
Returns a string that represents this AlgorithmIdentifier.
Overrides:
toString in class java.lang.Object
Returns:
the string representation