Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the correct verifier for RSA PSS scheme keys #625

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rdimitrov
Copy link
Contributor

@rdimitrov rdimitrov commented Mar 9, 2024

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:

Credits:

Thanks to @kairoaraujo for reaching out and helping track this together! 🚀 Cheers! 🍻

What's left:

  • Update the tests

@rdimitrov rdimitrov self-assigned this Mar 9, 2024
@rdimitrov rdimitrov added the bug label Mar 9, 2024
@rdimitrov rdimitrov marked this pull request as draft March 9, 2024 00:34
@kairoaraujo
Copy link

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

if !ok {
return &ErrType{Msg: "failed to convert public key to RSA PSS key"}
}
verifier, err = signature.LoadRSAPSSVerifier(publicKeyRSAPSS, hash, &rsa.PSSOptions{Hash: crypto.SHA256})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, if you're using the Verifier interface, you can also load a verifier with a PSS option now - https://github.com/sigstore/sigstore/blob/main/pkg/signature/signerverifier_test.go#L30-L38

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this only seems true for SignerVerifier, not Verifier

@jku
Copy link
Member

jku commented Aug 20, 2024

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
Copy link
Member

jku commented Aug 20, 2024

Just as an idea... I would love a keytype support test in tuf-conformance: theupdateframework/tuf-conformance#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 theupdateframework/tuf-conformance#167

jku added a commit to jku/tuf-conformance that referenced this pull request Aug 21, 2024
See theupdateframework/go-tuf#625

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants