Skip to content

Commit

Permalink
signer: Allow multiple signatures
Browse files Browse the repository at this point in the history
This makes it possible to sign the same metadata twice:
* currently this is only useful when fixing the keyid compliance issue
  in root (see theupdateframework#292). Basically the user will be asked to sign with
  both the keyid from root N+1 and the keyid from root N.
* there are clear use cases with one signer with multiple keys in
  future (think e.g. key rotation).
  • Loading branch information
jku committed May 17, 2024
1 parent 9bfba1e commit 653d58c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions signer/tuf_on_ci_sign/_signer_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,12 +742,12 @@ def status(self, rolename: str) -> str:
def sign(self, rolename: str):
"""Sign without payload changes"""
md = self.open(rolename)
signed = False
for key in self._get_keys(rolename):
keyowner = key.unrecognized_fields["x-tuf-on-ci-keyowner"]
if keyowner == self.user.name:
self._sign(rolename, md, key)
self._write(rolename, md)
return
signed = True

# Root is eligible to sign current root if the signer was valid
# in previous version
Expand All @@ -756,10 +756,12 @@ def sign(self, rolename: str):
keyowner = key.unrecognized_fields["x-tuf-on-ci-keyowner"]
if keyowner == self.user.name:
self._sign(rolename, md, key)
self._write(rolename, md)
return
signed = True

raise ValueError(f"{rolename} signing key for {self.user.name} not found")
if signed:
self._write(rolename, md)
else:
raise ValueError(f"{rolename} signing key for {self.user.name} not found")


def build_paths(rolename: str, depth: int) -> list[str]:
Expand Down

0 comments on commit 653d58c

Please sign in to comment.