Algorithm agility: PSS on the PKCS#11 shape, DSS TSA nonce, EC coverage - #478
Conversation
- #255: drive the DSS token from the signature parameters instead of the key, so a PSS-only certificate signs when the key reports plain RSA (the PKCS#11 shape). Reuse AbstractSignatureTokenConnection for the PSS parameters; request PSS under the portable RSASSA-PSS name and pin the key's provider, since setParameter-before-initSign defeats delayed provider selection and would reject a non-extractable token key. - #33: send an RFC 3161 nonce from the DSS engine and require the echo, switchable via engine.dss.tsa.nonce (default on). openpdf already did. - #23: EC signing tests on both engines; fixed by the OpenPDF 3 migration. Note dss writes ecdsa-with-SHA256 where openpdf writes id-ecPublicKey. - PrivateKeyInfo carries the keystore provider. Deferred: the --signature-algorithm selector, needed only to force PSS on an rsaEncryption certificate. See design-doc/3.2-algorithm-agility.md.
Provider pinning is required, not an optimisation: with the token's provider the key produces a PSS signature in hardware; without it, JCA resolves to SunRsaSign and fails with "key must be RSAPrivateKey".
|
PKCS#11 verified on hardware — Gemalto SafeNet eToken 5110 ( Same key, three attempts,
So provider pinning is what makes PSS work on this token at all — without it JCA resolves to SunRsaSign, which cannot take an opaque P11 key. Still not covered: a full PDF signing run on the token, which needs a certificate marked |
CLI run with an on-card key under an id-RSASSA-PSS certificate produces a PSS SignerInfo (SHA-256/MGF1/salt 32/trailer 1) that verifies.
|
End-to-end verified on the eToken 5110. Setup: fresh on-card RSA-2048 key ( Signed through the CLI, Salt length and trailer field match the RFC 4055 convention the BC-name fallback depends on, so both PSS paths are byte-compatible as claimed. On master this same run fails in Not covered: third-party validator acceptance (Adobe Reader) of the PSS output. |
PssTokenCertGen builds a certificate with an id-RSASSA-PSS SubjectPublicKeyInfo over a token-exported public key, giving the PSS-cert/RSA-key shape on hardware without any private-key operation on the token.
Closes #23, closes #33, closes #255.
Design:
design-doc/3.2-algorithm-agility.md. Three premises in the issue review were wrong; the doc andjsignpdf-issues-review.mdare corrected.#255 RSASSA-PSS (dss)
RSAunder anid-RSASSA-PSScertificate, so the token and the parameters disagreed and DSS threwThe SignatureAlgorithm within the SignatureValue 'RSA_SHA256' does not match ... 'RSA_SSA_PSS_SHA256_MGF1'.sign();AbstractSignatureTokenConnectionsupplies thePSSParameterSpec, and the engine passesparameters.getSignatureAlgorithm().getSignatureInstancerequests PSS under the portableRSASSA-PSSname and pins the key's provider.setParameterbeforeinitSignresolves the provider immediately, so delayed selection would pin SunRsaSign and reject a non-extractable token key.openpdfstructurally cannot emit PSS (no parameter slot in its SignerInfo writer).#33 TSA nonce (dss)
engine.dss.tsa.nonce, default on.openpdfalways sent one; DSS omits it unless aNonceSourceis set.EmbeddedTsaServercan now report the received nonce and echo a wrong one; the mismatch is rejected.#23 EC keys
dsswritesecdsa-with-SHA256,openpdfwritesid-ecPublicKey; documented, and the guide recommends-eng dssfor EC.Not covered
--signature-algorithmselector, whose only remaining function is forcing PSS on anrsaEncryptioncertificate.369 tests pass.