Use the correct verifier for RSA PSS scheme keys
The following PR fixes an issue with go-tuf's support for RSA key types.
Details:
Apparently for RSA key types signature.LoadVerifier() is defaulting to returning a verifier that is RSAPKCS1v15Verifier which corresponds to the RSA PKCS#1 scheme.
Based on the latest TUF spec, TUF uses RSA PSS instead of PKCS#1. This manifests itself by causing go-tuf v2 TUF clients to fail metadata verification in case of RSA key types.
The fix for this is to invoke the proper verifier for the PSS scheme. This means that when we are verifying a metadata signed by an RSA key type, we should use LoadRSAPSSVerifier() instead of the generic LoadVerifier().
References:
- https://theupdateframework.github.io/specification/latest/#file-formats-keys
- https://github.com/sigstore/sigstore/blob/a153736bf87443389feee6aa787e97b81839175d/pkg/signature/verifier.go#L41
Credits:
Thanks to @kairoaraujo for reaching out and helping track this together! 🚀 Cheers! 🍻
What's left:
- [ ] Update the tests
I've tested it, and it solves the issue 😃
Based on the latest TUF spec, TUF uses RSA PSS instead of PKCS#1
Note that these are just examples essentially, definitely not an exhaustive list of the only schemes that can be supported: I would avoid removing support for the pkcs1v15 scheme if possible as removing optional features can be a real head ache for users...
EDIT: the PR does not seem to remove the support, I just looked at comments originally and misunderstood
Just as an idea... I would love a keytype support test in tuf-conformance: https://github.com/theupdateframework/tuf-conformance/issues/159 -- implementing that would give you keytype test coverage "for free" in go-tuf and should not be more than 20 lines of code.
EDIT: I did an initial test in tuf-conformance https://github.com/theupdateframework/tuf-conformance/pull/167