-
Notifications
You must be signed in to change notification settings - Fork 50
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
include keyid in public ed25519/ecdsa public key files #250
include keyid in public ed25519/ecdsa public key files #250
Conversation
In the past we did not include the keyid in public ed25519/ecdsa key files. This commit changes this behavior and introduces a new argument to the `format_keyval_to_metadata` function. The argument is optional, so this should not have any affect on using `format_keyval_to_metadata` for keyid generation.
|
||
# If we encounter a keyid, we are dealing with pub key file generation | ||
# as in interface.py#L526 | ||
if keyid is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this check here is enough? Maybe we want to validate the keyid?
@@ -516,13 +516,15 @@ def generate_and_write_ed25519_keypair(filepath=None, password=None): | |||
# to final destination. | |||
file_object = tempfile.TemporaryFile() | |||
|
|||
# Generate the ed25519 public key file contents in metadata format (i.e., | |||
# does not include the keyid portion). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why we never included the keyid here? It doesn't make sense for me, because if we don't provide a filepath we are even naming the keypair files <KEYID>.{pub,key}
1 similar comment
mh funny that the coverage increased, I didn't even push tests?! |
Ok, I have tested the PR with in-toto with the following requirements.txt file for in-toto:
Then I did:
Then:
As you can see, we do include keyid's now for ed25519. Does |
In the past in-toto-keygen generated pubkeys did not have a public key ID in their JSON structure. This is going to change in the securesystemslib: secure-systems-lab/securesystemslib#250 This commit adds the key ID to all our public key tests + and the carol.pub key.
Thanks for pointing out this inconsistency and for proposing a fix, @shibumi! Your initiative is highly appreciated, however, I am against changing our custom public key format without a discussion why we came up with this format in the first place, and if the assumptions from back then still hold true. If we make a potentially breaking change, we might want to consider switching to a standard format altogether (we do use PEM for RSA keys on disk), or at least revise the included fields, e.g. why do ed25519/ecdsa private keys on disk include a keyid field and public keys don't, or why do both not include the Right now, securesystemslib and its dependents do know how to handle their keys. We can load public keys from disk (without keyid), keep them in memory (with keyid) and add them to in-toto layout metadata (with keyid), or in tuf root/targets metadata (without keyid). It would be good to make it very clear, when we use which format why. The various Moreover, the way we currently use the "serialization" function # simplified and slightly exaggerated for emphasis
a = key["a"]
b = key["b"]
c = key["c"]
metadata = format_keyval_to_metadata(a, b, c)
# metadata is {"a": "...", "b": "...", c: "...", d: "..."} |
Don't worry, I am good :D This was more of a quick fix. The discussion alone about this topic is more important. Do we want to keep this discussion in the PR or shall I compile an issue for it? |
An issue would be most welcome! Feel free to copy-paste whatever I wrote here or on slack. :) Btw. we already had a related issue, but I think I closed it due to it being partially addressed by our GPG subpackage and RSA key files being standard PEM. Here it is: #55 |
closing this PR, because discussion should be moved to the related issue. |
Please fill in the fields below to submit a pull request. The more information
that is provided, the better.
Fixes issue: in-toto/specification#33
Description of the changes being introduced by the pull request:
In the past we did not include the keyid in public ed25519/ecdsa key files. This commit changes this behavior and introduces a new argument to the
format_keyval_to_metadata
function. The argument is optional,so this should not have any affect on using
format_keyval_to_metadata
for keyid generation.Please verify and check that the pull request fulfils the following
requirements:
Do we need further tests/documentation for this change? The new argument is optional, so it should be API stable, however the generated public key itself may be different from now on. I have not tested this PR with in-toto-keygen yet.