TimeStampSigner: selecting SIGNATUREALGORITHM dynamically based on the request's messageImprint digest
#146
gustavoam-asdf
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
In
TimeStampSigner, the signature algorithm used to sign theTimeStampToken(CMSSignerInfo.signatureAlgorithm) is read from theSIGNATUREALGORITHMworker property and applied as-is:So a worker configured with, for example:
…will sign every
TimeStampTokenwith RSA-PSS over SHA-512, regardless of which digest algorithm the client used in the request'smessageImprint. ThemessageImprintis preserved unmodified inTSTInfo, which is the standards-compliant behavior, but the signature algorithm chosen by the TSA is fixed.I verified this against my own deployment (SignServer-CE 7.1.1): TSQs with
messageImprint.hashAlgorithm = sha256andsha512both yield TSTs signed with the sameSignerInfo.signatureAlgorithm = rsassaPss(SHA-512, MGF1-SHA-512). The behavior matches what I read inTimeStampSigner.javainmain.Use case / motivation
In our case we serve timestamps to a heterogeneous set of clients — some sign documents with SHA-256 + RSA PKCS#1 v1.5 (legacy ecosystem, public-sector validators that don't yet handle PSS), others with SHA-512 + PSS (modern PAdES-Baseline-T flows). We recently hit a real incompatibility where a strict validator rejected our TSTs because the TST was signed with RSASSA-PSS while the signer's own document signature was
sha256WithRSAEncryption. The validator's pipeline did not handle the algorithm mismatch gracefully.Today the only mitigation available is to fix
SIGNATUREALGORITHMto a single common-denominator value across all clients (we did this:SHA512WithRSA), losing the benefit of PSS for clients that would accept it.An alternative, currently-not-possible option would be: let the worker derive
signatureAlgorithmfrom the digest the client already chose in itsmessageImprint. The intuition is that a client capable of producing a SHA-256 imprint is signaling it lives in an ecosystem where SHA-256 is acceptable; matching the TST's signature digest to that gives a "naturally consistent" token without forcing the operator to converge on a single algorithm.Proposed configuration shape
Strawman — name and exact syntax up for discussion:
Semantics:
MESSAGEIMPRINT_SIGNATUREALGORITHM_MAPis unset, behavior is exactly today's —SIGNATUREALGORITHMapplied as-is. Fully backwards compatible.messageImprint.hashAlgorithmof the incoming TSQ in the map and uses the mappedsignatureAlgorithmto build theContentSigner.SIGNATUREALGORITHM(existing behavior).SHA256:SHA512WithRSAif they want to upgrade weak imprints with a stronger signature.ACCEPTEDALGORITHMScontinues to be the gatekeeper for which imprint algorithms the worker is willing to process at all.A simpler variant some operators might prefer is an
ADAPTIVE_SIGALG=trueflag that just derives sigalg from the imprint digest usingSHA256WithRSA/SHA384WithRSA/SHA512WithRSAautomatically — but the explicit map is more flexible (PSS vs PKCS#1 v1.5, hash mixing, etc.) and avoids hardcoded assumptions.Considerations / trade-offs I can already see
SignerInfo.signatureAlgorithm. Operators relying on "all my TSTs verify with one algorithm" lose that property. Mitigation: the feature is opt-in, off by default.DEFAULTTSAPOLICYOIDmay be tied (in the operator's CPS) to a specific sigalg. Operators enabling the map should ensure their CPS/policy declares all sigalgs they intend to emit. This is the operator's responsibility, not SignServer's.ACCEPTEDALGORITHMS: the operator decides what the floor is.Questions
MESSAGEIMPRINT_SIGNATUREALGORITHM_MAPfor backwards compat — be welcome?Happy to share more detail on the production use case if helpful. Thanks for considering.
Beta Was this translation helpful? Give feedback.
All reactions