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.
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
ALL_SIGNING_ALGORITHMS
All supported signing algorithms.
|
static ObjectIdentifier |
ANSIX962_EC_Public_Key_oid |
static ObjectIdentifier |
ANSIX962_SHA1_With_EC_oid |
static ObjectIdentifier |
DH_oid
Algorithm ID for Diffie Hellman Key agreement, from PKCS #3.
|
static ObjectIdentifier |
DH_PKIX_oid
Algorithm ID for the Diffie Hellman Key Agreement (DH), from the
IETF PKIX IPKI Part I.
|
static ObjectIdentifier |
DSA_oid
Algorithm ID for the Digital Signing Algorithm (DSA), from the
IETF PKIX IPKI Part I.
|
static ObjectIdentifier |
DSA_OIW_oid
Algorithm ID for the Digital Signing Algorithm (DSA), from the
NIST OIW Stable Agreements part 12.
|
static java.lang.String[] |
DSA_SIGNING_ALGORITHMS
Supported signing algorithms for a DSA key.
|
static java.lang.String[] |
EC_SIGNING_ALGORITHMS |
static ObjectIdentifier |
MD2_oid
Algorithm ID for the MD2 Message Digest Algorthm, from RFC 1319.
|
static ObjectIdentifier |
md2WithRSAEncryption_oid
Identifies a signing algorithm where an MD2 digest is encrypted
using an RSA private key; defined in PKCS #1.
|
static ObjectIdentifier |
MD5_oid
Algorithm ID for the MD5 Message Digest Algorthm, from RFC 1321.
|
static ObjectIdentifier |
md5WithRSAEncryption_oid
Identifies a signing algorithm where an MD5 digest is
encrypted using an RSA private key; defined in PKCS #1.
|
static ObjectIdentifier |
MGF1_oid |
protected DerValue |
params
Parameters for this algorithm.
|
protected java.lang.String |
paramsString |
static ObjectIdentifier |
RSA_oid
Algorithm ID for RSA keys used for any purpose, as defined in X.509.
|
static java.lang.String[] |
RSA_SIGNING_ALGORITHMS
Supported signing algorithms for a RSA key.
|
static ObjectIdentifier |
RSAEncryption_oid
Algorithm ID for RSA keys used with RSA encryption, as defined
in PKCS #1.
|
static ObjectIdentifier |
rsaPSS_oid |
static ObjectIdentifier |
SHA_oid
Algorithm ID for the SHA1 Message Digest Algorithm, from FIPS 180-1.
|
static ObjectIdentifier |
sha1WithDSA_oid
Identifies the FIPS 186 "Digital Signature Standard" (DSS), where a
SHA1 digest is signed using the Digital Signing Algorithm (DSA).
|
static ObjectIdentifier |
sha1WithDSA_OIW_oid
Identifies the FIPS 186 "Digital Signature Standard" (DSS), where a
SHA1 digest is signed using the Digital Signing Algorithm (DSA).
|
static ObjectIdentifier |
sha1WithEC_oid |
static ObjectIdentifier |
sha1WithRSAEncryption_oid
The proper one for sha1/rsa
|
static ObjectIdentifier |
sha1WithRSAEncryption_OIW_oid
Identifies a signing algorithm where an SHA1 digest is
encrypted using an RSA private key; defined in NIST OIW.
|
static ObjectIdentifier |
sha224WithEC_oid |
static ObjectIdentifier |
SHA256_oid |
static ObjectIdentifier |
sha256WithEC_oid |
static ObjectIdentifier |
sha256WithRSAEncryption_oid
The proper one for sha256/rsa
|
static ObjectIdentifier |
SHA384_oid |
static ObjectIdentifier |
sha384WithEC_oid |
static ObjectIdentifier |
sha384WithRSAEncryption_oid
The proper one for sha384/rsa
|
static ObjectIdentifier |
SHA512_oid |
static ObjectIdentifier |
sha512WithEC_oid |
static ObjectIdentifier |
sha512WithRSAEncryption_oid
The proper one for sha512/rsa
|
static ObjectIdentifier |
shaWithDSA_OIW_oid
Identifies the FIPS 186 "Digital Signature Standard" (DSS), where a
SHA digest is signed using the Digital Signing Algorithm (DSA).
|
Constructor and Description |
---|
AlgorithmId()
Deprecated.
use one of the other constructors.
|
AlgorithmId(ObjectIdentifier oid)
Constructs an algorithm ID with possible RSAPSS params.
|
AlgorithmId(ObjectIdentifier oid,
java.security.AlgorithmParameters params)
Constructs an algorithm ID with a fully encoded params object
|
AlgorithmId(ObjectIdentifier oid,
java.lang.String algName)
Constructor that takes the oid and name, so the name can be cachedf or laster use.
|
Modifier and Type | Method and Description |
---|---|
static java.security.AlgorithmParameters |
createPSSAlgorithmParameters(java.lang.String algName)
Used to create the PSS algorithm params needed for RSA PSS signatures.
|
static java.security.AlgorithmParameters |
createPSSAlgorithmParametersFromData(byte[] der) |
protected void |
decodeParams() |
void |
derEncode(java.io.OutputStream out)
DER encode this object onto an output stream.
|
void |
derEncodeWithContext(java.io.OutputStream out,
int contextVal)
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.lang.String algname)
Returns one of the algorithm IDs most commonly associated
with this algorithm name.
|
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() |
java.lang.String |
getParametersString() |
static java.lang.String[] |
getSigningAlgorithms(AlgorithmId alg)
Returns list of signing algorithms for a key algorithm such as
RSA or DSA.
|
int |
hashCode() |
protected java.lang.String |
paramsToString()
Provides a human-readable description of the algorithm parameters.
|
static AlgorithmId |
parse(byte[] val) |
static AlgorithmId |
parse(DerValue val)
Parse (unmarshal) an ID from a DER sequence input value.
|
void |
setParametersString(java.lang.String paramStr) |
java.lang.String |
toString()
Returns a string describing only the algorithm without parameters.
|
java.lang.String |
toStringWithParams()
Returns a string describing the algorithm and its parameters.
|
protected DerValue params
protected java.lang.String paramsString
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 MGF1_oid
public static final ObjectIdentifier ANSIX962_EC_Public_Key_oid
public static final ObjectIdentifier ANSIX962_SHA1_With_EC_oid
public static final ObjectIdentifier DH_oid
public static final ObjectIdentifier DH_PKIX_oid
public static final ObjectIdentifier DSA_OIW_oid
public static final ObjectIdentifier DSA_oid
public static final ObjectIdentifier RSA_oid
public static final ObjectIdentifier RSAEncryption_oid
public static final ObjectIdentifier sha1WithEC_oid
public static final ObjectIdentifier sha224WithEC_oid
public static final ObjectIdentifier sha256WithEC_oid
public static final ObjectIdentifier sha384WithEC_oid
public static final ObjectIdentifier sha512WithEC_oid
public static final ObjectIdentifier rsaPSS_oid
public static final ObjectIdentifier md2WithRSAEncryption_oid
public static final ObjectIdentifier md5WithRSAEncryption_oid
public static final ObjectIdentifier sha1WithRSAEncryption_oid
public static final ObjectIdentifier sha256WithRSAEncryption_oid
public static final ObjectIdentifier sha384WithRSAEncryption_oid
public static final ObjectIdentifier sha512WithRSAEncryption_oid
public static final ObjectIdentifier sha1WithRSAEncryption_OIW_oid
public static final ObjectIdentifier shaWithDSA_OIW_oid
public static final ObjectIdentifier sha1WithDSA_OIW_oid
public static final ObjectIdentifier sha1WithDSA_oid
public static final java.lang.String[] DSA_SIGNING_ALGORITHMS
public static final java.lang.String[] RSA_SIGNING_ALGORITHMS
public static final java.lang.String[] EC_SIGNING_ALGORITHMS
public static final java.lang.String[] ALL_SIGNING_ALGORITHMS
public AlgorithmId(ObjectIdentifier oid, java.security.AlgorithmParameters params) throws java.io.IOException, java.security.NoSuchAlgorithmException
oid
- the identifier for the algorithmparams
- the fully encoded AlgorithmIdentifier Objectjava.security.NoSuchAlgorithmException
java.io.IOException
public AlgorithmId(ObjectIdentifier oid, java.lang.String algName) throws java.io.IOException, java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
java.io.IOException
public AlgorithmId(ObjectIdentifier oid)
oid
- the identifier for the algorithm@Deprecated public AlgorithmId()
public java.security.AlgorithmParameters getParameters()
public java.lang.String getParametersString()
public void setParametersString(java.lang.String paramStr)
public static AlgorithmId get(java.lang.String algname) throws java.security.NoSuchAlgorithmException
algname
- the name being usedjava.security.NoSuchAlgorithmException
- on error.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.public static AlgorithmId parse(byte[] val) throws java.io.IOException
java.io.IOException
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 void derEncodeWithContext(java.io.OutputStream out, int contextVal) throws java.io.IOException
DerEncoder
interface.out
- the output stream on which to write the DER encoding params,
using context value.java.io.IOException
- on encoding error.public final byte[] encode() throws java.io.IOException
java.io.IOException
public static java.lang.String[] getSigningAlgorithms(AlgorithmId alg)
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.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toStringWithParams()
public byte[] getEncodedParams() throws java.io.IOException
java.io.IOException
protected java.lang.String paramsToString()
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 int hashCode()
hashCode
in class java.lang.Object
public final boolean equals(ObjectIdentifier id)
public static java.security.AlgorithmParameters createPSSAlgorithmParametersFromData(byte[] der) throws java.lang.Exception
java.lang.Exception
public static java.security.AlgorithmParameters createPSSAlgorithmParameters(java.lang.String algName) throws java.lang.IllegalArgumentException, java.security.NoSuchProviderException, java.security.spec.InvalidParameterSpecException, java.security.NoSuchAlgorithmException
java.lang.IllegalArgumentException
java.security.NoSuchProviderException
java.security.spec.InvalidParameterSpecException
java.security.NoSuchAlgorithmException