public class

AlgorithmId

extends Object
implements Serializable DerEncoder
java.lang.Object
   ↳ sun.security.x509.AlgorithmId
Known Direct Subclasses

Class Overview

This class identifies algorithms, such as cryptographic transforms, each of which may be associated with parameters. Instances of this base class are used when this runtime environment has no special knowledge of the algorithm type, and may also be used in other cases. Equivalence is defined according to OID and (where relevant) parameters.

Subclasses may be used, for example when when the algorithm ID has associated parameters which some code (e.g. code using public keys) needs to have parsed. Two examples of such algorithms are Diffie-Hellman key exchange, and the Digital Signature Standard Algorithm (DSS/DSA).

The OID constants defined in this class correspond to some widely used algorithms, for which conventional string names have been defined. This class is not a general repository for OIDs, or for such string names. Note that the mappings between algorithm IDs and algorithm names is not one-to-one.

Summary

Fields
public static final ObjectIdentifier DH_PKIX_oid
public static final ObjectIdentifier DH_oid
public static final ObjectIdentifier DSA_OIW_oid
public static final ObjectIdentifier DSA_oid
public static final ObjectIdentifier EC_oid
public static final ObjectIdentifier MD2_oid Algorithm ID for the MD2 Message Digest Algorthm, from RFC 1319.
public static final ObjectIdentifier MD5_oid Algorithm ID for the MD5 Message Digest Algorthm, from RFC 1321.
public static final ObjectIdentifier RSAEncryption_oid
public static final ObjectIdentifier RSA_oid
public static final ObjectIdentifier SHA256_oid
public static final ObjectIdentifier SHA384_oid
public static final ObjectIdentifier SHA512_oid
public static final ObjectIdentifier SHA_oid Algorithm ID for the SHA1 Message Digest Algorithm, from FIPS 180-1.
public static final ObjectIdentifier md2WithRSAEncryption_oid
public static final ObjectIdentifier md5WithRSAEncryption_oid
protected DerValue params Parameters for this algorithm.
public static final ObjectIdentifier pbeWithMD5AndDES_oid Algorithm ID for the PBE encryption algorithms from PKCS#5 and PKCS#12.
public static final ObjectIdentifier pbeWithMD5AndRC2_oid
public static final ObjectIdentifier pbeWithSHA1AndDES_oid
public static ObjectIdentifier pbeWithSHA1AndDESede_oid
public static ObjectIdentifier pbeWithSHA1AndRC2_40_oid
public static final ObjectIdentifier pbeWithSHA1AndRC2_oid
public static final ObjectIdentifier sha1WithDSA_OIW_oid
public static final ObjectIdentifier sha1WithDSA_oid
public static final ObjectIdentifier sha1WithECDSA_oid
public static final ObjectIdentifier sha1WithRSAEncryption_OIW_oid
public static final ObjectIdentifier sha1WithRSAEncryption_oid
public static final ObjectIdentifier sha224WithECDSA_oid
public static final ObjectIdentifier sha256WithECDSA_oid
public static final ObjectIdentifier sha256WithRSAEncryption_oid
public static final ObjectIdentifier sha384WithECDSA_oid
public static final ObjectIdentifier sha384WithRSAEncryption_oid
public static final ObjectIdentifier sha512WithECDSA_oid
public static final ObjectIdentifier sha512WithRSAEncryption_oid
public static final ObjectIdentifier shaWithDSA_OIW_oid
public static final ObjectIdentifier specifiedWithECDSA_oid
Public Constructors
AlgorithmId()
This constructor is deprecated. use one of the other constructors.
AlgorithmId(ObjectIdentifier oid)
Constructs a parameterless algorithm ID.
AlgorithmId(ObjectIdentifier oid, AlgorithmParameters algparams)
Constructs an algorithm ID with algorithm parameters.
Public Methods
void derEncode(OutputStream out)
DER encode this object onto an output stream.
final byte[] encode()
Returns the DER-encoded X.509 AlgorithmId as a byte array.
final void encode(DerOutputStream out)
Marshal a DER-encoded "AlgorithmID" sequence on the DER stream.
boolean equals(AlgorithmId other)
Returns true iff the argument indicates the same algorithm with the same parameters.
boolean equals(Object other)
Compares this AlgorithmID to another.
final boolean equals(ObjectIdentifier id)
Compares two algorithm IDs for equality.
static AlgorithmId get(String algname)
Returns one of the algorithm IDs most commonly associated with this algorithm name.
static AlgorithmId get(AlgorithmParameters algparams)
Returns one of the algorithm IDs most commonly associated with this algorithm parameters.
static AlgorithmId getAlgorithmId(String algname)
This method is deprecated. use the short get form of this method.
byte[] getEncodedParams()
Returns the DER encoded parameter, which can then be used to initialize java.security.AlgorithmParamters.
String getName()
Returns a name for the algorithm which may be more intelligible to humans than the algorithm's OID, but which won't necessarily be comprehensible on other systems.
final ObjectIdentifier getOID()
Returns the ISO OID for this algorithm.
AlgorithmParameters getParameters()
int hashCode()
Returns a hashcode for this AlgorithmId.
static AlgorithmId parse(DerValue val)
Parse (unmarshal) an ID from a DER sequence input value.
String toString()
Returns a string describing the algorithm and its parameters.
Protected Methods
void decodeParams()
String paramsToString()
Provides a human-readable description of the algorithm parameters.
[Expand]
Inherited Methods
From class java.lang.Object
From interface sun.security.util.DerEncoder

Fields

public static final ObjectIdentifier DH_PKIX_oid

public static final ObjectIdentifier DH_oid

public static final ObjectIdentifier DSA_OIW_oid

public static final ObjectIdentifier DSA_oid

public static final ObjectIdentifier EC_oid

public static final ObjectIdentifier MD2_oid

Algorithm ID for the MD2 Message Digest Algorthm, from RFC 1319. OID = 1.2.840.113549.2.2

public static final ObjectIdentifier MD5_oid

Algorithm ID for the MD5 Message Digest Algorthm, from RFC 1321. OID = 1.2.840.113549.2.5

public static final ObjectIdentifier RSAEncryption_oid

public static final ObjectIdentifier RSA_oid

public static final ObjectIdentifier SHA256_oid

public static final ObjectIdentifier SHA384_oid

public static final ObjectIdentifier SHA512_oid

public static final ObjectIdentifier SHA_oid

Algorithm ID for the SHA1 Message Digest Algorithm, from FIPS 180-1. This is sometimes called "SHA", though that is often confusing since many people refer to FIPS 180 (which has an error) as defining SHA. OID = 1.3.14.3.2.26. Old SHA-0 OID: 1.3.14.3.2.18.

public static final ObjectIdentifier md2WithRSAEncryption_oid

public static final ObjectIdentifier md5WithRSAEncryption_oid

protected DerValue params

Parameters for this algorithm. These are stored in unparsed DER-encoded form; subclasses can be made to automaticaly parse them so there is fast access to these parameters.

public static final ObjectIdentifier pbeWithMD5AndDES_oid

Algorithm ID for the PBE encryption algorithms from PKCS#5 and PKCS#12.

public static final ObjectIdentifier pbeWithMD5AndRC2_oid

public static final ObjectIdentifier pbeWithSHA1AndDES_oid

public static ObjectIdentifier pbeWithSHA1AndDESede_oid

public static ObjectIdentifier pbeWithSHA1AndRC2_40_oid

public static final ObjectIdentifier pbeWithSHA1AndRC2_oid

public static final ObjectIdentifier sha1WithDSA_OIW_oid

public static final ObjectIdentifier sha1WithDSA_oid

public static final ObjectIdentifier sha1WithECDSA_oid

public static final ObjectIdentifier sha1WithRSAEncryption_OIW_oid

public static final ObjectIdentifier sha1WithRSAEncryption_oid

public static final ObjectIdentifier sha224WithECDSA_oid

public static final ObjectIdentifier sha256WithECDSA_oid

public static final ObjectIdentifier sha256WithRSAEncryption_oid

public static final ObjectIdentifier sha384WithECDSA_oid

public static final ObjectIdentifier sha384WithRSAEncryption_oid

public static final ObjectIdentifier sha512WithECDSA_oid

public static final ObjectIdentifier sha512WithRSAEncryption_oid

public static final ObjectIdentifier shaWithDSA_OIW_oid

public static final ObjectIdentifier specifiedWithECDSA_oid

Public Constructors

public AlgorithmId ()

This constructor is deprecated.
use one of the other constructors.

Constructs an algorithm ID which will be initialized separately, for example by deserialization.

public AlgorithmId (ObjectIdentifier oid)

Constructs a parameterless algorithm ID.

Parameters
oid the identifier for the algorithm

public AlgorithmId (ObjectIdentifier oid, AlgorithmParameters algparams)

Constructs an algorithm ID with algorithm parameters.

Parameters
oid the identifier for the algorithm.
algparams the associated algorithm parameters.

Public Methods

public void derEncode (OutputStream out)

DER encode this object onto an output stream. Implements the DerEncoder interface.

Parameters
out the output stream on which to write the DER encoding.
Throws
IOException on encoding error.

public final byte[] encode ()

Returns the DER-encoded X.509 AlgorithmId as a byte array.

Throws
IOException

public final void encode (DerOutputStream out)

Marshal a DER-encoded "AlgorithmID" sequence on the DER stream.

Throws
IOException

public boolean equals (AlgorithmId other)

Returns true iff the argument indicates the same algorithm with the same parameters.

public boolean equals (Object other)

Compares this AlgorithmID to another. If algorithm parameters are available, they are compared. Otherwise, just the object IDs for the algorithm are compared.

Parameters
other preferably an AlgorithmId, else an ObjectIdentifier
Returns
  • true if this object is the same as the obj argument; false otherwise.

public final boolean equals (ObjectIdentifier id)

Compares two algorithm IDs for equality. Returns true iff they are the same algorithm, ignoring algorithm parameters.

public static AlgorithmId get (String algname)

Returns one of the algorithm IDs most commonly associated with this algorithm name.

Parameters
algname the name being used
Throws
NoSuchAlgorithmException on error.

public static AlgorithmId get (AlgorithmParameters algparams)

Returns one of the algorithm IDs most commonly associated with this algorithm parameters.

Parameters
algparams the associated algorithm parameters.
Throws
NoSuchAlgorithmException on error.

public static AlgorithmId getAlgorithmId (String algname)

This method is deprecated.
use the short get form of this method.

Returns one of the algorithm IDs most commonly associated with this algorithm name.

Parameters
algname the name being used
Throws
NoSuchAlgorithmException on error.

public byte[] getEncodedParams ()

Returns the DER encoded parameter, which can then be used to initialize java.security.AlgorithmParamters.

Returns
  • DER encoded parameters, or null not present.
Throws
IOException

public String getName ()

Returns a name for the algorithm which may be more intelligible to humans than the algorithm's OID, but which won't necessarily be comprehensible on other systems. For example, this might return a name such as "MD5withRSA" for a signature algorithm on some systems. It also returns names like "OID.1.2.3.4", when no particular name for the algorithm is known.

public final ObjectIdentifier getOID ()

Returns the ISO OID for this algorithm. This is usually converted to a string and used as part of an algorithm name, for example "OID.1.3.14.3.2.13" style notation. Use the getName call when you do not need to ensure cross-system portability of algorithm names, or need a user friendly name.

public AlgorithmParameters getParameters ()

public int hashCode ()

Returns a hashcode for this AlgorithmId.

Returns
  • a hashcode for this AlgorithmId.

public static AlgorithmId parse (DerValue val)

Parse (unmarshal) an ID from a DER sequence input value. This form parsing might be used when expanding a value which has already been partially unmarshaled as a set or sequence member.

Parameters
val the input value, which contains the algid and, if there are any parameters, those parameters.
Returns
  • an ID for the algorithm. If the system is configured appropriately, this may be an instance of a class with some kind of special support for this algorithm. In that case, you may "narrow" the type of the ID.
Throws
IOException on error.

public String toString ()

Returns a string describing the algorithm and its parameters.

Returns
  • a string representation of the object.

Protected Methods

protected void decodeParams ()

Throws
IOException

protected String paramsToString ()

Provides a human-readable description of the algorithm parameters. This may be redefined by subclasses which parse those parameters.