Interface GenericJcaSignatureContext.SignLengthResolver

Enclosing class:
GenericJcaSignatureContext
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface GenericJcaSignatureContext.SignLengthResolver
Strategy for determining the signature trailer length in SIGN mode.

The resolver is evaluated before the signing engine is created and may probe a provider when the length is not fixed by specification.

  • Method Details

    • resolve

      int resolve(PrivateKey privateKey) throws GeneralSecurityException
      Resolves the signature length for a given private key in SIGN mode.
      Parameters:
      privateKey - private key used for signing
      Returns:
      exact number of bytes Signature.sign() will produce
      Throws:
      GeneralSecurityException - if the length cannot be determined
    • fixed

      Returns a resolver that always reports a fixed length.
      Parameters:
      len - positive length in bytes
      Returns:
      resolver returning len
      Throws:
      IllegalArgumentException - if len <= 0
    • probeWith

      static GenericJcaSignatureContext.SignLengthResolver probeWith(String jcaAlg, String providerName)
      Returns a resolver that probes a JCA Signature by signing an empty message.

      Useful for algorithms/providers where the produced length is not trivially known from parameters.

      Parameters:
      jcaAlg - JCA signature name (for example, "SHA256withRSA", "Ed25519")
      providerName - optional provider name; null selects the highest-priority provider
      Returns:
      resolver that initializes a Signature for signing and returns sign().length