Class AlgorithmIdentifier
java.lang.Object
org.bouncycastle.asn1.ASN1Object
org.bouncycastle.asn1.x509.AlgorithmIdentifier
- All Implemented Interfaces:
ASN1Encodable, Encodable
-
Constructor Summary
ConstructorsConstructorDescriptionAlgorithmIdentifier(ASN1ObjectIdentifier algorithm) AlgorithmIdentifier(ASN1ObjectIdentifier algorithm, ASN1Encodable parameters) -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturn true if two algorithm identifiers name the same algorithm carrying the same parameters, counting an absent parameters field and an explicitNULLas the same thing - both say "this algorithm takes no parameters", they simply say it differently.static AlgorithmIdentifiergetInstance(Object obj) static AlgorithmIdentifiergetInstance(ASN1TaggedObject taggedObject, boolean declaredExplicit) static AlgorithmIdentifiergetTagged(ASN1TaggedObject taggedObject, boolean declaredExplicit) Produce an object suitable for an ASN1OutputStream.Methods inherited from class ASN1Object
encodeTo, encodeTo, equals, getEncoded, getEncoded, hasEncodedTagValue, hashCode
-
Constructor Details
-
AlgorithmIdentifier
-
AlgorithmIdentifier
-
-
Method Details
-
getInstance
-
getInstance
public static AlgorithmIdentifier getInstance(ASN1TaggedObject taggedObject, boolean declaredExplicit) -
getTagged
public static AlgorithmIdentifier getTagged(ASN1TaggedObject taggedObject, boolean declaredExplicit) -
getAlgorithm
-
getParameters
-
areEquivalent
Return true if two algorithm identifiers name the same algorithm carrying the same parameters, counting an absent parameters field and an explicitNULLas 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.- Parameters:
a- an algorithm identifier, may be null.b- an algorithm identifier, may be null.- Returns:
- true if the two name the same algorithm with the same parameters.
-
toASN1Primitive
Produce an object suitable for an ASN1OutputStream.AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY DEFINED BY algorithm OPTIONAL }- Specified by:
toASN1Primitivein interfaceASN1Encodable- Specified by:
toASN1Primitivein classASN1Object- Returns:
- a primitive representation of this object.
-