@@ -960,7 +960,13 @@ def is_in_trusted_paths(self, target_filepath: str) -> bool:
960960 is in one of the trusted paths of DelegatedRole"""
961961
962962 if self .path_hash_prefixes is not None :
963- target_filepath_hash = _get_filepath_hash (target_filepath )
963+ # Calculate the hash of the filepath to determine which bin
964+ # to find the target. The client currently assumes the repository
965+ # uses sslib's default algorithm to generate hashes.
966+ digest_object = sslib_hash .digest ()
967+ digest_object .update (target_filepath .encode ("utf-8" ))
968+ target_filepath_hash = digest_object .hexdigest ()
969+
964970 for path_hash_prefix in self .path_hash_prefixes :
965971 if target_filepath_hash .startswith (path_hash_prefix ):
966972 return True
@@ -980,21 +986,6 @@ def is_in_trusted_paths(self, target_filepath: str) -> bool:
980986 return False
981987
982988
983- def _get_filepath_hash (target_filepath , hash_function = "sha256" ):
984- """
985- Calculate the hash of the filepath to determine which bin to find the
986- target.
987- """
988- # The client currently assumes the repository (i.e., repository
989- # tool) uses 'hash_function' to generate hashes and UTF-8.
990- digest_object = sslib_hash .digest (hash_function )
991- encoded_target_filepath = target_filepath .encode ("utf-8" )
992- digest_object .update (encoded_target_filepath )
993- target_filepath_hash = digest_object .hexdigest ()
994-
995- return target_filepath_hash
996-
997-
998989class Delegations :
999990 """A container object storing information about all delegations.
1000991
0 commit comments