@@ -358,6 +358,11 @@ def generate_ecdsa_key(algorithm='ecdsa-sha2-nistp256'):
358358 ecdsa_key ['keyid' ] = keyid
359359 ecdsa_key ['keyval' ] = key_value
360360
361+ # Add "keyid_hash_algorithms" so that equal ECDSA keys with different keyids
362+ # can be associated using supported keyid_hash_algorithms.
363+ ecdsa_key ['keyid_hash_algorithms' ] = \
364+ securesystemslib .settings .HASH_ALGORITHMS
365+
361366 return ecdsa_key
362367
363368
@@ -1244,6 +1249,11 @@ def import_rsakey_from_public_pem(pem):
12441249 rsakey_dict ['keyid' ] = keyid
12451250 rsakey_dict ['keyval' ] = key_value
12461251
1252+ # Add "keyid_hash_algorithms" so that equal RSA keys with different keyids
1253+ # can be associated using supported keyid_hash_algorithms.
1254+ rsakey_dict ['keyid_hash_algorithms' ] = \
1255+ securesystemslib .settings .HASH_ALGORITHMS
1256+
12471257 return rsakey_dict
12481258
12491259
@@ -1315,6 +1325,11 @@ def import_rsakey_from_pem(pem):
13151325 rsakey_dict ['keyid' ] = keyid
13161326 rsakey_dict ['keyval' ] = key_value
13171327
1328+ # Add "keyid_hash_algorithms" so that equal RSA keys with
1329+ # different keyids can be associated using supported keyid_hash_algorithms.
1330+ rsakey_dict ['keyid_hash_algorithms' ] = \
1331+ securesystemslib .settings .HASH_ALGORITHMS
1332+
13181333 return rsakey_dict
13191334
13201335
@@ -1893,6 +1908,11 @@ def import_ecdsakey_from_private_pem(pem, password=None):
18931908 ecdsakey_dict ['keyid' ] = keyid
18941909 ecdsakey_dict ['keyval' ] = key_value
18951910
1911+ # Add "keyid_hash_algorithms" so equal ECDSA keys with
1912+ # different keyids can be associated using supported keyid_hash_algorithms
1913+ ecdsakey_dict ['keyid_hash_algorithms' ] = \
1914+ securesystemslib .settings .HASH_ALGORITHMS
1915+
18961916 return ecdsakey_dict
18971917
18981918
@@ -1971,6 +1991,11 @@ def import_ecdsakey_from_public_pem(pem):
19711991 ecdsakey_dict ['keyid' ] = keyid
19721992 ecdsakey_dict ['keyval' ] = key_value
19731993
1994+ # Add "keyid_hash_algorithms" so that equal ECDSA keys with different keyids
1995+ # can be associated using supported keyid_hash_algorithms.
1996+ ecdsakey_dict ['keyid_hash_algorithms' ] = \
1997+ securesystemslib .settings .HASH_ALGORITHMS
1998+
19741999 return ecdsakey_dict
19752000
19762001
0 commit comments