go-tuf icon indicating copy to clipboard operation
go-tuf copied to clipboard

Use the correct verifier for RSA PSS scheme keys

Open rdimitrov opened this issue 1 year ago • 3 comments

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

rdimitrov avatar Mar 09 '24 00:03 rdimitrov

I've tested it, and it solves the issue 😃

kairoaraujo avatar Mar 09 '24 09:03 kairoaraujo

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

jku avatar Aug 20 '24 09:08 jku

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

jku avatar Aug 20 '24 10:08 jku