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

Refactor SCT verification/CT key handling #263

Closed
woodruffw opened this issue Oct 20, 2022 · 4 comments · Fixed by #267
Closed

Refactor SCT verification/CT key handling #263

woodruffw opened this issue Oct 20, 2022 · 4 comments · Fixed by #267
Labels
bug Something isn't working component:signing Core signing functionality component:verification Core verification functionality

Comments

@woodruffw
Copy link
Member

This has come to light during the staging instance's recent sharding: there are now multiple CT signing keys, instead of just ctfe.pub. The newer signing keys aren't necessarily compatible with the older ones (i.e. they can be ECDSA instead of RSA), and new CT entries are signed with the latest key rather than the older ones.

As a result, our assumption of a single CT key (ctfe.{staging.}pub) is no longer correct. This makes SCT verification fail for newer SCTs, since they're no longer signed with the key that we've vendored.

To fix this, we need to refactor our CT key handling. In particular:

  • Instead of a single CT key, we need a "keychain" of CT keys. That keychain will be essentially a dict[KeyID, Key], where KeyID is the key ID format described in RFC 6962 s. 3.2.
  • When verifying an SCT, the keyring will select the correct CT key using the SCT's logID field, which is really just the key ID.

For the time being, we'll create this keychain by vendoring more CT keys (#262). Longer term, the TUF integration planned under #25 will be expected to retrieve all CT key targets, either via their usage metadata or some other identifying feature in the TUF repo.

@woodruffw woodruffw added bug Something isn't working component:signing Core signing functionality component:verification Core verification functionality labels Oct 20, 2022
@woodruffw
Copy link
Member Author

This also has some nice refactoring benefits: we'll be able to define an API like this:

class CTKeyring:
    def verify(self, key_id: bytes, signature: bytes, digitally_signed: bytes) -> ...:
        ...

...and hide some of the current implementation details.

@woodruffw
Copy link
Member Author

#262 will vendor the new staging instance CT keys. From there, we'll need the keyring impl.

@asraa
Copy link
Contributor

asraa commented Oct 20, 2022

Looks good to me!

Another refactoring benefit: I would suggest moving CTFE keys out of the rekor instance (

verify_sct(sct, cert, chain, self._rekor._ctfe_pubkey)
) and into its own module or next to fulcio -- rekor actually has no interaction with it, but fulcio does post it's certs to it (ct for certs, rekor for signing events).

@woodruffw
Copy link
Member Author

#267 has the initial refactor here.

I would suggest moving CTFE keys out of the rekor instance

I agree, although JFYI I didn't include this change in that refactor (yet). I want to think a bit more about how that'll look with the other refactor I have planned (#250).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component:signing Core signing functionality component:verification Core verification functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants