Top Description Fields Constructors Methods
sun.security.x509

public Class AlgorithmId

extends Object
implements Serializable, DerEncoder
Class Inheritance
All Implemented Interfaces
sun.security.util.DerEncoder, java.io.Serializable
Known Direct Subclasses
sun.security.x509.AlgIdDSA
Imports
java.io.*, java.util.*, java.util.concurrent.ConcurrentHashMap, java.security.*, sun.security.util.*

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 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.

Authors
David Brownell, Amit Kapoor, Hemma Prafullchandra

Field Summary

Modifier and TypeField and Description
private ObjectIdentifier
algid

The object identifier being used for this algorithm.

private AlgorithmParameters
private static volatile Map<String, String>
public static final ObjectIdentifier
public static final ObjectIdentifier
protected transient byte[]
encodedParams

Parameters for this algorithm.

public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
private static final long
serialVersionUID

use serialVersionUID from JDK 1.1.

public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier

Constructor Summary

AccessConstructor and Description
public
AlgorithmId()
Deprecated use one of the other constructors.

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

public
AlgorithmId(ObjectIdentifier
the identifier for the algorithm
oid
)

Constructs a parameterless algorithm ID.

public
AlgorithmId(ObjectIdentifier
the identifier for the algorithm.
oid
,
AlgorithmParameters
the associated algorithm parameters, can be null.
algparams
)

Constructs an algorithm ID with algorithm parameters.

public
AlgorithmId(ObjectIdentifier
the identifier for the algorithm.
oid
,
DerValue
the associated algorithm parameters, can be null.
params
)

Constructs an algorithm ID with algorithm parameters as a DerValue.

Method Summary

Modifier and TypeMethod and Description
private static ObjectIdentifier
algOID(String name)

private static Map<String, String>
public static void
private static ConcurrentHashMap<String, String>
protected void
public void
encode(DerOutputStream
the output stream on which to write the DER encoding.
out
)

Implements sun.security.util.DerEncoder.encode.

DER encode this object onto an output stream.

public final byte[]
encode()

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

public boolean
equals(AlgorithmId other)

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

public boolean
equals(Object
preferably an AlgorithmId, else an ObjectIdentifier
other
)

Overrides java.lang.Object.equals.

Compares this AlgorithmID to another.

public final boolean
equals(ObjectIdentifier id)

Compares two algorithm IDs for equality.

public static AlgorithmId
get(String
the name being used
algname
)

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

public static AlgorithmId
get(AlgorithmParameters
the associated algorithm parameters.
algparams
)

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

public static AlgorithmId
getAlgorithmId(String
the name being used
algname
)
Deprecated use the short get form of this method.

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

public byte[]

Returns:

DER encoded parameters, or null not present.
getEncodedParams
()

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

public String
getName()

Returns a name for the algorithm which can be used by getInstance() call of a crypto primitive.

public final ObjectIdentifier
getOID()

Returns the ISO OID for this algorithm.

public AlgorithmParameters
public int

Returns:

a hashcode for this AlgorithmId
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hashcode for this AlgorithmId.

private static boolean
protected String
paramsToString()

Provides a human-readable description of the algorithm parameters.

public static AlgorithmId

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.
parse
(DerValue
the input value, which contains the algid and, if there are any parameters, those parameters.
val
)

Parse (unmarshal) an ID from a DER sequence input value.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string describing the algorithm and its parameters.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

algidback to summary
private ObjectIdentifier algid

The object identifier being used for this algorithm.

algParamsback to summary
private AlgorithmParameters algParams
Annotations
@SuppressWarnings:serial
aliasOidsTableback to summary
private static volatile Map<String, String> aliasOidsTable
DSA_oidback to summary
public static final ObjectIdentifier DSA_oid
EC_oidback to summary
public static final ObjectIdentifier EC_oid
encodedParamsback to summary
protected transient byte[] encodedParams

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

MD2_oidback to summary
public static final ObjectIdentifier MD2_oid
MD2withRSA_oidback to summary
public static final ObjectIdentifier MD2withRSA_oid
MD5_oidback to summary
public static final ObjectIdentifier MD5_oid
MD5withRSA_oidback to summary
public static final ObjectIdentifier MD5withRSA_oid
MGF1_oidback to summary
public static final ObjectIdentifier MGF1_oid
RSAEncryption_oidback to summary
public static final ObjectIdentifier RSAEncryption_oid
RSASSA_PSS_oidback to summary
public static final ObjectIdentifier RSASSA_PSS_oid
serialVersionUIDback to summary
private static final long serialVersionUID

use serialVersionUID from JDK 1.1. for interoperability

Annotations
@Serial
SHA1withRSA_oidback to summary
public static final ObjectIdentifier SHA1withRSA_oid
SHA224_oidback to summary
public static final ObjectIdentifier SHA224_oid
SHA224withRSA_oidback to summary
public static final ObjectIdentifier SHA224withRSA_oid
SHA256_oidback to summary
public static final ObjectIdentifier SHA256_oid
SHA256withRSA_oidback to summary
public static final ObjectIdentifier SHA256withRSA_oid
SHA384_oidback to summary
public static final ObjectIdentifier SHA384_oid
SHA384withRSA_oidback to summary
public static final ObjectIdentifier SHA384withRSA_oid
SHA3_224_oidback to summary
public static final ObjectIdentifier SHA3_224_oid
SHA3_224withRSA_oidback to summary
public static final ObjectIdentifier SHA3_224withRSA_oid
SHA3_256_oidback to summary
public static final ObjectIdentifier SHA3_256_oid
SHA3_256withRSA_oidback to summary
public static final ObjectIdentifier SHA3_256withRSA_oid
SHA3_384_oidback to summary
public static final ObjectIdentifier SHA3_384_oid
SHA3_384withRSA_oidback to summary
public static final ObjectIdentifier SHA3_384withRSA_oid
SHA3_512_oidback to summary
public static final ObjectIdentifier SHA3_512_oid
SHA3_512withRSA_oidback to summary
public static final ObjectIdentifier SHA3_512withRSA_oid
SHA512$224withRSA_oidback to summary
public static final ObjectIdentifier SHA512$224withRSA_oid
SHA512$256withRSA_oidback to summary
public static final ObjectIdentifier SHA512$256withRSA_oid
SHA512_224_oidback to summary
public static final ObjectIdentifier SHA512_224_oid
SHA512_256_oidback to summary
public static final ObjectIdentifier SHA512_256_oid
SHA512_oidback to summary
public static final ObjectIdentifier SHA512_oid
SHA512withRSA_oidback to summary
public static final ObjectIdentifier SHA512withRSA_oid
SHA_oidback to summary
public static final ObjectIdentifier SHA_oid

Constructor Detail

AlgorithmIdback to summary
public AlgorithmId()

Deprecated

use one of the other constructors.

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

Annotations
@Deprecated
AlgorithmIdback to summary
public AlgorithmId(ObjectIdentifier oid)

Constructs a parameterless algorithm ID.

Parameters
oid:ObjectIdentifier

the identifier for the algorithm

AlgorithmIdback to summary
public AlgorithmId(ObjectIdentifier oid, AlgorithmParameters algparams)

Constructs an algorithm ID with algorithm parameters.

Parameters
oid:ObjectIdentifier

the identifier for the algorithm.

algparams:AlgorithmParameters

the associated algorithm parameters, can be null.

Exceptions
IllegalStateException:
if algparams is not initialized or cannot be encoded
AlgorithmIdback to summary
public AlgorithmId(ObjectIdentifier oid, DerValue params) throws IOException

Constructs an algorithm ID with algorithm parameters as a DerValue.

Parameters
oid:ObjectIdentifier

the identifier for the algorithm.

params:DerValue

the associated algorithm parameters, can be null.

Method Detail

algOIDback to summary
private static ObjectIdentifier algOID(String name) throws IOException
aliasOidsTableback to summary
private static Map<String, String> aliasOidsTable()
clearAliasOidsTableback to summary
public static void clearAliasOidsTable()
collectOIDAliasesback to summary
private static ConcurrentHashMap<String, String> collectOIDAliases()
decodeParamsback to summary
protected void decodeParams() throws IOException
encodeback to summary
public void encode(DerOutputStream out)

Implements sun.security.util.DerEncoder.encode.

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

Parameters
out:DerOutputStream

the output stream on which to write the DER encoding.

Annotations
@Override
encodeback to summary
public final byte[] encode()

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

equalsback to summary
public boolean equals(AlgorithmId other)

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

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

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:Object

preferably an AlgorithmId, else an ObjectIdentifier

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
equalsback to summary
public final boolean equals(ObjectIdentifier id)

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

getback to summary
public static AlgorithmId get(String algname) throws NoSuchAlgorithmException

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

Parameters
algname:String

the name being used

Exceptions
NoSuchAlgorithmException:
on error.
getback to summary
public static AlgorithmId get(AlgorithmParameters algparams) throws NoSuchAlgorithmException

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

Parameters
algparams:AlgorithmParameters

the associated algorithm parameters.

Exceptions
NoSuchAlgorithmException:
on error.
IllegalStateException:
if algparams is not initialized or cannot be encoded
getAlgorithmIdback to summary
public static AlgorithmId getAlgorithmId(String algname) throws NoSuchAlgorithmException

Deprecated

use the short get form of this method.

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

Parameters
algname:String

the name being used

Annotations
@Deprecated
Exceptions
NoSuchAlgorithmException:
on error.
getEncodedParamsback to summary
public byte[] getEncodedParams()

Returns the DER encoded parameter, which can then be used to initialize java.security.AlgorithmParameters. Note that this* method should always return a new array as it is called directly by the JDK implementation of X509Certificate.getSigAlgParams() and X509CRL.getSigAlgParams().

Note

for ecdsa-with-SHA2 plus hash algorithm (Ex: SHA-256), this method returns null because getName() has already returned the "full" signature algorithm (Ex: SHA256withECDSA).

Returns:byte[]

DER encoded parameters, or null not present.

getNameback to summary
public String getName()

Returns a name for the algorithm which can be used by getInstance() call of a crypto primitive. The name is usually 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 OID names like "1.2.3.4", when no particular name for the algorithm is known. The OID may also be recognized by getInstance() calls since an OID is usually defined as an alias for an algorithm by the security provider. In some special cases where the OID does not include enough info to return a Java standard algorithm name, an algorithm name that includes info on the params is returned: 1. For ecdsa-with-SHA2 plus hash algorithm (Ex: SHA-256), this method returns the "full" signature algorithm (Ex: SHA256withECDSA) directly. 2. For PBES2, this method returns the "full" cipher name containing the KDF and Enc algorithms (Ex: PBEWithHmacSHA256AndAES_256) directly.

getOIDback to summary
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.

getParametersback to summary
public AlgorithmParameters getParameters()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hashcode for this AlgorithmId.

Returns:int

a hashcode for this AlgorithmId

Annotations
@Override
isKnownProviderback to summary
private static boolean isKnownProvider(Provider p)
paramsToStringback to summary
protected String paramsToString()

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

parseback to summary
public static AlgorithmId parse(DerValue val) throws IOException

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:DerValue

the input value, which contains the algid and, if there are any parameters, those parameters.

Returns:AlgorithmId

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.

Exceptions
IOException:
on error.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string describing the algorithm and its parameters.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override