public class AlgorithmIdentifier extends ASN1Object
| Constructor and Description |
|---|
AlgorithmIdentifier(ASN1ObjectIdentifier algorithm) |
AlgorithmIdentifier(ASN1ObjectIdentifier algorithm,
ASN1Encodable parameters) |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
areEquivalent(AlgorithmIdentifier a,
AlgorithmIdentifier b)
Return true if two algorithm identifiers name the same algorithm carrying the same
parameters, counting an absent parameters field and an explicit
NULL as the same
thing - both say "this algorithm takes no parameters", they simply say it differently. |
ASN1ObjectIdentifier |
getAlgorithm() |
static AlgorithmIdentifier |
getInstance(ASN1TaggedObject taggedObject,
boolean declaredExplicit) |
static AlgorithmIdentifier |
getInstance(java.lang.Object obj) |
ASN1Encodable |
getParameters() |
static AlgorithmIdentifier |
getTagged(ASN1TaggedObject taggedObject,
boolean declaredExplicit) |
ASN1Primitive |
toASN1Primitive()
Produce an object suitable for an ASN1OutputStream.
|
encodeTo, encodeTo, equals, getEncoded, getEncoded, hasEncodedTagValue, hashCodepublic AlgorithmIdentifier(ASN1ObjectIdentifier algorithm)
public AlgorithmIdentifier(ASN1ObjectIdentifier algorithm, ASN1Encodable parameters)
public static AlgorithmIdentifier getInstance(java.lang.Object obj)
public static AlgorithmIdentifier getInstance(ASN1TaggedObject taggedObject, boolean declaredExplicit)
public static AlgorithmIdentifier getTagged(ASN1TaggedObject taggedObject, boolean declaredExplicit)
public ASN1ObjectIdentifier getAlgorithm()
public ASN1Encodable getParameters()
public static boolean areEquivalent(AlgorithmIdentifier a, AlgorithmIdentifier b)
NULL as the same
thing - both say "this algorithm takes no parameters", they simply say it differently.
The two encodings are both in wide use for the SHA-2 digests, and
RFC 5754 sec. 2 requires a
receiver to take either: "Implementations MUST accept SHA2 AlgorithmIdentifiers with
absent parameters. Implementations MUST accept SHA2 AlgorithmIdentifiers with NULL
parameters." - while requiring that they be generated with the parameters
absent. ASN1Object.equals(Object) compares the encodings and so separates them, which is right
for a map key but wrong for deciding whether a peer named the algorithm we expected.
Note this only equates absent with NULL; an identifier carrying an actual parameter
structure is never equivalent to one carrying none.
a - an algorithm identifier, may be null.b - an algorithm identifier, may be null.public ASN1Primitive toASN1Primitive()
AlgorithmIdentifier ::= SEQUENCE {
algorithm OBJECT IDENTIFIER,
parameters ANY DEFINED BY algorithm OPTIONAL }
toASN1Primitive in interface ASN1EncodabletoASN1Primitive in class ASN1Object