Skip to content

Commit

Permalink
feat: add key name to root.json if defined
Browse files Browse the repository at this point in the history
  • Loading branch information
renatav committed Jan 11, 2025
1 parent e185ef8 commit 0c08165
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion taf/tuf/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ def create(
of public keys that should be registered as the corresponding role's keys, but the private
keys are not available. E.g. keys exporeted from YubiKeys of maintainers who are not
present at the time of the repository's creation
key_name_mappings: A dictionary whose keys are key ids and values are custom names of those keys
"""
# TODO add verification keys
# support yubikeys
Expand Down Expand Up @@ -555,10 +556,12 @@ def create(
key_id = _get_legacy_keyid(signer.public_key)
self.signer_cache[role.name][key_id] = signer
for public_key in public_keys[role.name].values():
key_id = _get_legacy_keyid(public_key)
if key_id in key_name_mappings:
public_key.unrecognized_fields["name"] = key_name_mappings[key_id]
root.add_key(public_key, role.name)
root.roles[role.name].threshold = role.threshold

root.unrecognized_fields["key_names"] = key_name_mappings
targets = Targets()
target_roles = {"targets": targets}
delegations_per_parent: Dict[str, Dict] = defaultdict(dict)
Expand Down

0 comments on commit 0c08165

Please sign in to comment.