|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--iaik.asn1.structures.AlgorithmID
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!
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 |
protected static java.util.Hashtable implementations
public static AlgorithmID dhKeyAgreement
Diffie-Hellman key exchange algorithm.
AlgorithmID.dhKeyAgreement.public static AlgorithmID rsaEncryption
RSA encryption signature algorithm.
AlgorithmID.rsaEncryption.public static AlgorithmID rsaESOAEP
RSA encryption signature algorithm,
using the OAEP encoding scheme defined in PKCS-1 v2.0
AlgorithmID.rsaESOAEP.public static AlgorithmID mgf1
MGF1 mask generation algorithm used in PKCS-1 v2.0.
AlgorithmID.mgf1.public static AlgorithmID md2WithRSAEncryption
md2WithRSAEncryption signature algorithm.
AlgorithmID.md2WithRSAEncryption.public static AlgorithmID md4WithRSAEncryption
md4WithRSAEncryption signature algorithm.
AlgorithmID.md4WithRSAEncryption.public static AlgorithmID md5WithRSAEncryption
md5WithRSAEncryption signature algorithm.
AlgorithmID.md5WithRSAEncryption.public static AlgorithmID sha1WithRSAEncryption
sha1WithRSAEncryption signature algorithm.
AlgorithmID.sha1WithRSAEncryption.public static AlgorithmID dsa
DSA signature algorithm.
AlgorithmID.dsa.public static AlgorithmID dsaX957
DSA signature algorithm,
using the OID defined in the X.957 standard.
AlgorithmID.dsaX957.public static AlgorithmID dsaWithSHA
dsaWithSHA signature algorithm.
AlgorithmID.dsaWithSHA.public static AlgorithmID dsaWithSHA1
dsaWithSHA1 signature algorithm.
AlgorithmID.dsaWithSHA1.public static AlgorithmID pbeWithMD5AndDES_CBC
pbeWithMD5AndDES_CBC key-encryption algorithm
as defined by PKCS#5.
AlgorithmID.pbeWithMD5AndDES_CBC.public static AlgorithmID pbeWithSHAAnd128BitRC4
pbeWithSHAAnd128BitRC4 key-encryption algorithm
as defined by PKCS#12.
AlgorithmID.pbeWithSHAAnd128BitRC4.public static AlgorithmID pbeWithSHAAnd40BitRC4
pbeWithSHAAnd40BitRC4 key-encryption algorithm
as defined by PKCS#12.
AlgorithmID.pbeWithSHAAnd40BitRC4.public static AlgorithmID pbeWithSHAAnd3_KeyTripleDES_CBC
pbeWithSHAAnd3_KeyTripleDES_CBC key-encryption algorithm
as defined by PKCS#12.
AlgorithmID.pbeWithSHAAnd3_KeyTripleDES_CBC.public static AlgorithmID pbeWithSHAAnd2_KeyTripleDES_CBC
pbeWithSHAAnd2_KeyTripleDES_CBC key-encryption algorithm
as defined by PKCS#12.
AlgorithmID.pbeWithSHAAnd2_KeyTripleDES_CBC.public static AlgorithmID pbeWithSHAAnd128BitRC2_CBC
pbeWithSHAAnd128BitRC2_CBC key-encryption algorithm
as defined by PKCS#12.
AlgorithmID.pbeWithSHAAnd128BitRC2_CBC.public static AlgorithmID pbeWithSHAAnd40BitRC2_CBC
pbeWithSHAAnd40BitRC2_CBC key-encryption algorithm
as defined by PKCS#12.
AlgorithmID.pbeWithSHAAnd40BitRC2_CBC.public static AlgorithmID rsa
RSA public key algorithm.
AlgorithmID.rsa.public static AlgorithmID rc2_CBC
RC2 symmetric block cipher used in CBC mode.
AlgorithmID.rc2_CBC.public static AlgorithmID rc4
RC4 stream cipher.
AlgorithmID.rc4.public static AlgorithmID des_EDE3_CBC
Triple DES symmetric block cipher used in CBC mode.
AlgorithmID.des_EDE3_CBC.public static AlgorithmID des_CBC
DES symmetric block cipher used in CBC mode.
AlgorithmID.des_CBC.public static AlgorithmID idea_CBC
IDEA symmetric block cipher used in CBC mode.
AlgorithmID.des_CBC.public static AlgorithmID cast5_CBC
CAST5 symmetric block cipher used in CBC mode.
AlgorithmID.cast5_CBC.public static AlgorithmID rc5_CBC
RC5 symmetric block cipher used in CBC mode.
AlgorithmID.rc5_CBC.public static AlgorithmID md2
MD2 message digest algorithm.
AlgorithmID.md2.public static AlgorithmID md4
MD4 message digest algorithm.
AlgorithmID.md4.public static AlgorithmID md5
MD5 message digest algorithm.
AlgorithmID.md5.public static AlgorithmID sha
SHA message digest algorithm.
AlgorithmID.sha.public static AlgorithmID sha1
SHA1 message digest algorithm which is the same as SHA.
AlgorithmID.sha1.| Constructor Detail |
public AlgorithmID()
null ObjectID and
null parameters.
public AlgorithmID(java.lang.String objectID,
java.lang.String name)
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"
public AlgorithmID(java.lang.String objectID,
java.lang.String name,
java.lang.String implementationName)
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"public AlgorithmID(ObjectID algorithm)
algorithm - the ObjectID of the algorithm
public AlgorithmID(ObjectID algorithm,
ASN1Object parameter)
algorithm - the ObjectID of the algorithmparameter - the algorithm parameters
public AlgorithmID(ASN1Object algorithmID)
throws CodingException
toASN1Object()
method.algorithmID - the AlgorithmID as ASN1Object
public AlgorithmID(DerInputStream is)
throws java.io.IOException
The given DerInputStream supplies
DER encoded data that represents an already existing AlgorithmID.
is - the DerInputStream supplying the DER encoded ASN1Object| Method Detail |
public static boolean changeObjectID(AlgorithmID algID,
ObjectID oid)
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).algID - the AlgorithmID to which a new OID shall be allocatedoid - the new object identifier
public static boolean changeOIDString(AlgorithmID algID,
java.lang.String oidString)
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).algID - the AlgorithmID to which a new OID shall be allocatedoid - the new object identifier
public void decode(ASN1Object algorithmID)
throws CodingException
The supplied ASN1Object represents an already existing AlgorithmID that may
have been created by means of the toASN1Object()
method.
algorithmID - the AlgorithmID as ASN1Objectpublic ASN1Object toASN1Object()
SEQUENCE
public java.lang.String getImplementationName()
throws NoSuchAlgorithmException
public java.lang.Object getInstance()
throws NoSuchAlgorithmException
public Cipher getCipherInstance()
throws NoSuchAlgorithmException
public Signature getSignatureInstance()
throws NoSuchAlgorithmException
public MessageDigest getMessageDigestInstance()
throws NoSuchAlgorithmException
public KeyAgreement getKeyAgreementInstance()
throws NoSuchAlgorithmException
public KeyFactory getKeyFactoryInstance()
throws NoSuchAlgorithmException
public java.lang.Object clone()
public ObjectID getAlgorithm()
ObjectIDpublic ASN1Object getParameter()
public AlgorithmParameters getAlgorithmParameters(java.lang.String algorithm)
throws NoSuchAlgorithmException
java.security.AlgorithmParameters object.algorithm - the name of the algorithm the parameters belong topublic void setAlgorithmParameters(AlgorithmParameters parameters)
java.security.AlgorithmParameters object.parameters - the parameters of the algorithmpublic void setParameter(ASN1Object parameters)
parameters - the parameters of the algorithmpublic java.lang.String getName()
public boolean equals(java.lang.Object obj)
obj - the other AlgorithmIDtrue, if the two AlgorithmIDs are equal, false otherwisepublic java.lang.String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||