Class DefaultDigestAlgorithmIdentifierFinder

java.lang.Object
org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder
All Implemented Interfaces:
DigestAlgorithmIdentifierFinder

public class DefaultDigestAlgorithmIdentifierFinder extends Object implements DigestAlgorithmIdentifierFinder
Default implementation of DigestAlgorithmIdentifierFinder, returning the AlgorithmIdentifier that names a digest in the contexts where this finder is used by CMS / S/MIME / PKIX operator builders.

Parameter-field convention: SHA-2 and SHA-3 digest identifiers are produced with the parameters field absent, per RFC 5754 §2: "Implementations MUST generate SHA2 AlgorithmIdentifiers with absent parameters." SHA-1 keeps NULL parameters (RFC 3370). Old algorithms with historic NULL-parameter conventions (MD2 / MD4 / MD5, GOST R 34.11-94) follow their own RFCs.

This is a different convention from DefaultSignatureAlgorithmIdentifierFinder, which when building RSASSA-PSS-params emits the SHA-2 / SHA-3 hash sub-identifier with NULL parameters per RFC 4055 §2.1 (sha256Identifier ::= { id-sha256, NULL } etc.). Both forms are standards-compliant in their respective slots; a single CMS SignedData carrying an RSA-PSS SignerInfo will validly contain the same SHA-2 OID twice, once with absent parameters (in digestAlgorithm) and once with NULL parameters (inside the PSS parameter structure). Receiver-side AlgorithmIdentifier.equals() on the two encodings returns false but both are accepted by RFC 5754 §2 and by other mainstream verifiers (OpenSSL, the JDK providers, GnuTLS).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bouncycastle.asn1.x509.AlgorithmIdentifier
    find(String digAlgName)
    Find the algorithm identifier that matches with the passed in digest name.
    org.bouncycastle.asn1.x509.AlgorithmIdentifier
    find(org.bouncycastle.asn1.ASN1ObjectIdentifier digAlgOid)
    Find the algorithm identifier that matches with the passed in digest OID.
    org.bouncycastle.asn1.x509.AlgorithmIdentifier
    find(org.bouncycastle.asn1.x509.AlgorithmIdentifier sigAlgId)
    Find the digest algorithm identifier that matches with the passed in signature algorithm identifier.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • DefaultDigestAlgorithmIdentifierFinder

      public DefaultDigestAlgorithmIdentifierFinder()
  • Method Details

    • find

      public org.bouncycastle.asn1.x509.AlgorithmIdentifier find(org.bouncycastle.asn1.x509.AlgorithmIdentifier sigAlgId)
      Description copied from interface: DigestAlgorithmIdentifierFinder
      Find the digest algorithm identifier that matches with the passed in signature algorithm identifier.
      Specified by:
      find in interface DigestAlgorithmIdentifierFinder
      Parameters:
      sigAlgId - the signature algorithm of interest.
      Returns:
      an algorithm identifier for the corresponding digest.
    • find

      public org.bouncycastle.asn1.x509.AlgorithmIdentifier find(org.bouncycastle.asn1.ASN1ObjectIdentifier digAlgOid)
      Description copied from interface: DigestAlgorithmIdentifierFinder
      Find the algorithm identifier that matches with the passed in digest OID.
      Specified by:
      find in interface DigestAlgorithmIdentifierFinder
      Parameters:
      digAlgOid - the OID of the digest algorithm of interest.
      Returns:
      an algorithm identifier for the digest signature.
    • find

      public org.bouncycastle.asn1.x509.AlgorithmIdentifier find(String digAlgName)
      Description copied from interface: DigestAlgorithmIdentifierFinder
      Find the algorithm identifier that matches with the passed in digest name.
      Specified by:
      find in interface DigestAlgorithmIdentifierFinder
      Parameters:
      digAlgName - the name of the digest algorithm of interest.
      Returns:
      an algorithm identifier for the digest signature.