Skip to content

Commit

Permalink
client: new root sigs only counted once per keyid
Browse files Browse the repository at this point in the history
When verifying newly downloaded root metadata with the keys listed in the
root metadata being verified, multiple signatures with the same keyid
should not be counted towards the threshold. A keyid should only count
once towards the threshold.

This fixes the _verify_root_self_signed() method introduced in PR #1101 to
ensure that keyids are only counted once when verifying a threshold of new
root signatures.

Signed-off-by: Joshua Lock <[email protected]>
  • Loading branch information
joshuagl committed Nov 24, 2020
1 parent 71cb004 commit 83ac7be
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tuf/client/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ def _verify_root_self_signed(self, signable):
signatures = signable['signatures']
signed = securesystemslib.formats.encode_canonical(
signable['signed']).encode('utf-8')
validated = 0
verified_sig_keyids = set()

for signature in signatures:
keyid = signature['keyid']
Expand All @@ -1403,9 +1403,9 @@ def _verify_root_self_signed(self, signable):
valid_sig = securesystemslib.keys.verify_signature(key, signature, signed)

if valid_sig:
validated = validated + 1
verified_sig_keyids.add(keyid)

if validated >= threshold:
if len(verified_sig_keyids) >= threshold:
return True
return False

Expand Down

0 comments on commit 83ac7be

Please sign in to comment.