Skip to content

Commit ab30113

Browse files
committed
client: new root sigs only counted once per keyid
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]>
1 parent 4cc04d3 commit ab30113

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tuf/client/updater.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ def _verify_root_self_signed(self, signable):
13851385
signatures = signable['signatures']
13861386
signed = securesystemslib.formats.encode_canonical(
13871387
signable['signed']).encode('utf-8')
1388-
validated = 0
1388+
verified_sig_keyids = []
13891389

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

14051405
if valid_sig:
1406-
validated = validated + 1
1406+
verified_sig_keyids.append(keyid)
14071407

1408-
if validated >= threshold:
1408+
# A signature with a given keyid should only count towards the threshold
1409+
# once. Convert the list of keyids into a set, in order to uniquify them
1410+
# and therefore count each keyid only once towards the threshold.
1411+
if len(set(verified_sig_keyids)) >= threshold:
14091412
return True
14101413
return False
14111414

0 commit comments

Comments
 (0)