Package zeroecho.core.alg.common.sig
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.
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 Summary
Modifier and TypeMethodDescriptionfixed(int len) Returns a resolver that always reports a fixed length.Returns a resolver that probes a JCASignatureby signing an empty message.intresolve(PrivateKey privateKey) Resolves the signature length for a given private key in SIGN mode.
-
Method Details
-
resolve
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- iflen<= 0
-
probeWith
Returns a resolver that probes a JCASignatureby 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;nullselects the highest-priority provider- Returns:
- resolver that initializes a
Signaturefor signing and returnssign().length
-