public class AlgorithmId extends java.lang.Object implements java.io.Serializable, DerEncoder
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.
Constructor and Description |
---|
AlgorithmId()
Deprecated.
use one of the other constructors.
|
AlgorithmId(ObjectIdentifier oid)
Constructs a parameterless algorithm ID.
|
AlgorithmId(ObjectIdentifier oid,
java.security.AlgorithmParameters algparams)
Constructs an algorithm ID with algorithm parameters.
|
Modifier and Type | Method and Description |
---|---|
protected void |
decodeParams() |
void |
derEncode(java.io.OutputStream out)
DER encode this object onto an output stream.
|
byte[] |
encode()
Returns the DER-encoded X.509 AlgorithmId as a byte array.
|
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(java.lang.Object other)
Compares this AlgorithmID to another.
|
boolean |
equals(ObjectIdentifier id)
Compares two algorithm IDs for equality.
|
static AlgorithmId |
get(java.security.AlgorithmParameters algparams)
Returns one of the algorithm IDs most commonly associated
with this algorithm parameters.
|
static AlgorithmId |
get(java.lang.String algname)
Returns one of the algorithm IDs most commonly associated
with this algorithm name.
|
static AlgorithmId |
getAlgorithmId(java.lang.String algname)
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.
|
java.lang.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.
|
ObjectIdentifier |
getOID()
Returns the ISO OID for this algorithm.
|
java.security.AlgorithmParameters |
getParameters() |
int |
hashCode()
Returns a hashcode for this AlgorithmId.
|
protected java.lang.String |
paramsToString()
Provides a human-readable description of the algorithm parameters.
|
static AlgorithmId |
parse(DerValue val)
Parse (unmarshal) an ID from a DER sequence input value.
|
java.lang.String |
toString()
Returns a string describing the algorithm and its parameters.
|
protected static org.slf4j.Logger logger
protected DerValue params
public static final ObjectIdentifier MD2_oid
public static final ObjectIdentifier MD5_oid
public static final ObjectIdentifier SHA_oid
public static final ObjectIdentifier SHA256_oid
public static final ObjectIdentifier SHA384_oid
public static final ObjectIdentifier SHA512_oid
public static final ObjectIdentifier DH_oid
public static final ObjectIdentifier DH_PKIX_oid
public static final ObjectIdentifier DSA_oid
public static final ObjectIdentifier DSA_OIW_oid
public static final ObjectIdentifier EC_oid
public static final ObjectIdentifier RSA_oid
public static final ObjectIdentifier RSAEncryption_oid
public static final ObjectIdentifier md2WithRSAEncryption_oid
public static final ObjectIdentifier md5WithRSAEncryption_oid
public static final ObjectIdentifier sha1WithRSAEncryption_oid
public static final ObjectIdentifier sha1WithRSAEncryption_OIW_oid
public static final ObjectIdentifier sha256WithRSAEncryption_oid
public static final ObjectIdentifier sha384WithRSAEncryption_oid
public static final ObjectIdentifier sha512WithRSAEncryption_oid
public static final ObjectIdentifier shaWithDSA_OIW_oid
public static final ObjectIdentifier sha1WithDSA_OIW_oid
public static final ObjectIdentifier sha1WithDSA_oid
public static final ObjectIdentifier sha1WithECDSA_oid
public static final ObjectIdentifier sha224WithECDSA_oid
public static final ObjectIdentifier sha256WithECDSA_oid
public static final ObjectIdentifier sha384WithECDSA_oid
public static final ObjectIdentifier sha512WithECDSA_oid
public static final ObjectIdentifier specifiedWithECDSA_oid
public static final ObjectIdentifier pbeWithMD5AndDES_oid
public static final ObjectIdentifier pbeWithMD5AndRC2_oid
public static final ObjectIdentifier pbeWithSHA1AndDES_oid
public static final ObjectIdentifier pbeWithSHA1AndRC2_oid
public static ObjectIdentifier pbeWithSHA1AndDESede_oid
public static ObjectIdentifier pbeWithSHA1AndRC2_40_oid
@Deprecated public AlgorithmId()
public AlgorithmId(ObjectIdentifier oid)
oid
- the identifier for the algorithmpublic AlgorithmId(ObjectIdentifier oid, java.security.AlgorithmParameters algparams)
oid
- the identifier for the algorithm.algparams
- the associated algorithm parameters.protected void decodeParams() throws java.io.IOException
java.io.IOException
public final void encode(DerOutputStream out) throws java.io.IOException
java.io.IOException
public void derEncode(java.io.OutputStream out) throws java.io.IOException
DerEncoder
interface.derEncode
in interface DerEncoder
out
- the output stream on which to write the DER encoding.java.io.IOException
- on encoding error.public final byte[] encode() throws java.io.IOException
java.io.IOException
public final ObjectIdentifier getOID()
getName
call when you do not need to ensure cross-system portability
of algorithm names, or need a user friendly name.public java.lang.String getName()
public java.security.AlgorithmParameters getParameters()
public byte[] getEncodedParams() throws java.io.IOException
java.io.IOException
public boolean equals(AlgorithmId other)
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- preferably an AlgorithmId, else an ObjectIdentifierpublic final boolean equals(ObjectIdentifier id)
public int hashCode()
hashCode
in class java.lang.Object
protected java.lang.String paramsToString()
public java.lang.String toString()
toString
in class java.lang.Object
public static AlgorithmId parse(DerValue val) throws java.io.IOException
val
- the input value, which contains the algid and, if
there are any parameters, those parameters.java.io.IOException
- on error.@Deprecated public static AlgorithmId getAlgorithmId(java.lang.String algname) throws java.security.NoSuchAlgorithmException
algname
- the name being usedjava.security.NoSuchAlgorithmException
- on error.public static AlgorithmId get(java.lang.String algname) throws java.security.NoSuchAlgorithmException
algname
- the name being usedjava.security.NoSuchAlgorithmException
- on error.public static AlgorithmId get(java.security.AlgorithmParameters algparams) throws java.security.NoSuchAlgorithmException
algparams
- the associated algorithm parameters.java.security.NoSuchAlgorithmException
- on error.Copyright © 2025. All rights reserved.