Repository navigation
Fix keyids in the 1.0 spec - #43
Merged
Merged
Conversation
Member
|
Thanks for the PR @erickt! I just extracted all the keys from the spec and generated new keyids. I confirm that your patch correctly updates all occurrences of keyids of keys defined in the spec's exemplary It does, however, not update the keyids for a key defined in Do you want to make the change here, or should I submit a follow-up PR? |
Member
|
Btw. here's the script I used to re-gerneate the keys: from securesystemslib.formats import encode_canonical
from securesystemslib.hash import digest
spec_keys = {
'1a2b4110927d4cba257262f614896179ff85ca1f1353a41b5224ac474ca71cb4': {'keytype': 'ed25519', 'scheme': 'ed25519', 'keyval': {'public': '72378e5bc588793e58f81c8533da64a2e8f1565c1fcc7f253496394ffc52542c'}},
'93ec2c3dec7cc08922179320ccd8c346234bf7f21705268b93e990d5273a2a3b': {'keytype': 'ed25519', 'scheme': 'ed25519', 'keyval': {'public': '68ead6e54a43f8f36f9717b10669d1ef0ebb38cee6b05317669341309f1069cb'}},
'f2d5020d08aea06a0a9192eb6a4f549e17032ebefa1aa9ac167c1e3e727930d6': {'keytype': 'ed25519', 'scheme': 'ed25519', 'keyval': {'public': '66dd78c5c2a78abc6fc6b267ff1a8017ba0e8bfc853dd97af351949bba021275'}},
'fce9cf1cc86b0945d6a042f334026f31ed8e4ee1510218f198e8d3f191d15309': {'keytype': 'ed25519', 'scheme': 'ed25519', 'keyval': {'public': '01c61f8dc7d77fcef973f4267927541e355e8ceda757e2c402818dad850f856e'}},
'ce3e02e72980b09ca6f5efa68197130b381921e5d0675e2e0c8f3c47e0626bba': {'keytype': 'ed25519', 'scheme': 'ed25519', 'keyval': {'public': 'b6e40fb71a6041212a3d84331336ecaa1f48a0c523f80ccc762a034c727606fa'}}
}
for old_keyid, key in spec_keys.items():
canonical_key_bytes = encode_canonical(key).encode("utf-8")
hasher = digest("sha256")
hasher.update(canonical_key_bytes)
new_keyid = hasher.hexdigest()
print(old_keyid, " --> ", new_keyid) |
It looks like the sample Key IDs in the 1.0 spec were not updated
to the TUF 1.0 algorithm. For example:
```
>>> key_meta = { "keytype": "ed25519", "keyval": { "public": "72378e5bc588793e58f81c8533da64a2e8f1565c1fcc7f253496394ffc52542c" } }
>>> key_update_data = securesystemslib.formats.encode_canonical(key_meta)
>>> digest_object = securesystemslib.hash.digest("sha256")
>>> digest_object.update(key_update_data.encode('utf-8'))
>>> digest_object.hexdigest()
'1a2b4110927d4cba257262f614896179ff85ca1f1353a41b5224ac474ca71cb4'
>>>
>>> key_meta = { "keytype": "ed25519", "scheme": "ed25519", "keyval": { "public": "72378e5bc588793e58f81c8533da64a2e8f1565c1fcc7f253496394ffc52542c" } }
>>> key_update_data = securesystemslib.formats.encode_canonical(key_meta)
>>> digest_object = securesystemslib.hash.digest("sha256")
>>> digest_object.update(key_update_data.encode('utf-8'))
>>> digest_object.hexdigest()
'1bf1c6e3cdd3d3a8420b19199e27511999850f4b376c4547b2f32fba7e80fca3'
```
This updates the keys to be calculated with the new algorithm,
which includes the `"method"` in the key metadata.
Member
|
@erickt, I just realized that I have push access to your branch. :) So I added the missing keyid update myself and amended your last commit. Thanks again for the contribution. |
Contributor
Author
|
@lukpueh no problem! thanks for merging this in! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It looks like the sample Key IDs in the 1.0 spec were not updated to the TUF 1.0 algorithm. For example:
This updates the keys to be calculated with the new algorithm, which includes the
"method"in the key metadata.edit: I was wrong, all the key ids were using the old algorithm. I updated this PR to also rewrite those key ids.