public class AlgorithmId extends java.lang.Object implements java.io.Serializable, DerEncoder
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.
| 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.
|
AlgorithmId(ObjectIdentifier oid,
DerValue params)
Constructs an algorithm ID with algorithm parameters as a DerValue.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
clearAliasOidsTable() |
protected void |
decodeParams() |
byte[] |
encode()
Returns the DER-encoded X.509 AlgorithmId as a byte array.
|
void |
encode(DerOutputStream out)
DER encode this object onto an output 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.AlgorithmParameters.
|
java.lang.String |
getName()
Returns a name for the algorithm which can be used by getInstance()
call of a crypto primitive.
|
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 transient byte[] encodedParams
public static final ObjectIdentifier SM2_OID
public static final ObjectIdentifier SM3_OID
public static final ObjectIdentifier SM3withSM2_OID
public static final ObjectIdentifier MD2_oid
public static final ObjectIdentifier MD5_oid
public static final ObjectIdentifier SHA_oid
public static final ObjectIdentifier SHA224_oid
public static final ObjectIdentifier SHA256_oid
public static final ObjectIdentifier SHA384_oid
public static final ObjectIdentifier SHA512_oid
public static final ObjectIdentifier SHA512_224_oid
public static final ObjectIdentifier SHA512_256_oid
public static final ObjectIdentifier SHA3_224_oid
public static final ObjectIdentifier SHA3_256_oid
public static final ObjectIdentifier SHA3_384_oid
public static final ObjectIdentifier SHA3_512_oid
public static final ObjectIdentifier DSA_oid
public static final ObjectIdentifier EC_oid
public static final ObjectIdentifier RSAEncryption_oid
public static final ObjectIdentifier RSASSA_PSS_oid
public static final ObjectIdentifier MGF1_oid
public static final ObjectIdentifier ed25519_oid
public static final ObjectIdentifier ed448_oid
public static final ObjectIdentifier x25519_oid
public static final ObjectIdentifier x448_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
@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, can be null.public AlgorithmId(ObjectIdentifier oid, DerValue params) throws java.io.IOException
oid - the identifier for the algorithm.params - the associated algorithm parameters, can be null.java.io.IOExceptionprotected void decodeParams()
throws java.io.IOException
java.io.IOExceptionpublic void encode(DerOutputStream out) throws java.io.IOException
DerEncoder interface.encode in interface DerEncoderout - 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.IOExceptionpublic 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()
getName() has already returned the "full"
signature algorithm (Ex: SHA256withECDSA).public boolean equals(AlgorithmId other)
public boolean equals(java.lang.Object other)
equals in class java.lang.Objectother - preferably an AlgorithmId, else an ObjectIdentifierpublic final boolean equals(ObjectIdentifier id)
public int hashCode()
hashCode in class java.lang.Objectprotected java.lang.String paramsToString()
public java.lang.String toString()
toString in class java.lang.Objectpublic 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.java.lang.IllegalStateException - if algparams is not initialized
or cannot be encodedpublic static void clearAliasOidsTable()