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

ecdsa keyval.public format is hex-encoded DER, should be PEM #223

Closed
jku opened this issue Feb 14, 2022 · 3 comments · Fixed by #357
Closed

ecdsa keyval.public format is hex-encoded DER, should be PEM #223

jku opened this issue Feb 14, 2022 · 3 comments · Fixed by #357

Comments

@jku
Copy link
Member

jku commented Feb 14, 2022

It looks like the ecdsa-sha2-nistp256 keytypes keyval.public value is incorrectly the hex encoded raw bytes of the key, instead of PEM. Spec says:

The "ecdsa-sha2-nistp256" format is:

{
  "keytype" : "ecdsa-sha2-nistp256",
  "scheme" : "ecdsa-sha2-nistp256",
  "keyval" : {
    "public" : PUBLIC
  }
}

PUBLIC: PEM format and a string.

I'm looking at e.g the sigstore metadata https://github.com/sigstore/root-signing/blob/main/repository/repository/2.root.json#L36 where the value does not seem to be PEM.

Related:

@asraa
Copy link
Contributor

asraa commented Feb 14, 2022

I think the big problem was that newlines inside JSON couldn't be handled well with go. I pulled a PEM encoded public key string from python repository testadata and you'll usually get invalid chars trying to unmarshal:
https://go.dev/play/p/WikoJBIBMRo

@jku
Copy link
Member Author

jku commented Feb 15, 2022

I realize the following is not useful to solve the problem that we have now but I'll say this to any future developers thinking of a similar workaround: Redefining an existing keytype is not the best solution to this problem. The specification supports new keytypes just fine.

I don't have ideas to fix the issue at hand: I'm not very familiar with the go deployment styles but I suppose we are now in a situation where:

  • current clients only accept hex ecdsa keys
  • even if client code is updated to support both, there is no guarantee that clients are updated
  • even if the metadata generating code is fixed, repositories currently serving hex ecdsa keys might not want to switch to PEM keys because of above point

What the project can definitely do is document the issue: "go-tuf does X in a non-compliant way: it works fine but may prevent using other TUF implementations with the same metadata"

@toby-jn
Copy link
Contributor

toby-jn commented Apr 16, 2022

Implemented a fix for this in: #270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants