diff --git a/tuf/client/updater.py b/tuf/client/updater.py index 629f8e21..99321978 100755 --- a/tuf/client/updater.py +++ b/tuf/client/updater.py @@ -133,6 +133,7 @@ from securesystemslib import exceptions as sslib_exceptions from securesystemslib import formats as sslib_formats +from securesystemslib import hash as sslib_hash from securesystemslib import keys as sslib_keys from securesystemslib import util as sslib_util @@ -148,7 +149,6 @@ import tuf.requests_fetcher import tuf.keydb -import securesystemslib.hash import six # The Timestamp role does not have signed metadata about it; otherwise we @@ -1207,7 +1207,7 @@ def _check_hashes(self, file_object, trusted_hashes): # Verify each hash, raise an exception if any hash fails to verify for algorithm, trusted_hash in six.iteritems(trusted_hashes): - digest_object = securesystemslib.hash.digest_fileobject(file_object, + digest_object = sslib_hash.digest_fileobject(file_object, algorithm) computed_hash = digest_object.hexdigest() @@ -2933,7 +2933,7 @@ def _get_target_hash(self, target_filepath, hash_function='sha256'): # Calculate the hash of the filepath to determine which bin to find the # target. The client currently assumes the repository (i.e., repository # tool) uses 'hash_function' to generate hashes and UTF-8. - digest_object = securesystemslib.hash.digest(hash_function) + digest_object = sslib_hash.digest(hash_function) encoded_target_filepath = target_filepath.encode('utf-8') digest_object.update(encoded_target_filepath) target_filepath_hash = digest_object.hexdigest() @@ -3088,7 +3088,7 @@ def updated_targets(self, targets, destination_directory): for algorithm, digest in six.iteritems(target['fileinfo']['hashes']): digest_object = None try: - digest_object = securesystemslib.hash.digest_filename(target_filepath, + digest_object = sslib_hash.digest_filename(target_filepath, algorithm=algorithm) # This exception would occur if the target does not exist locally. diff --git a/tuf/repository_lib.py b/tuf/repository_lib.py index 4a1b8e8d..0384ad66 100644 --- a/tuf/repository_lib.py +++ b/tuf/repository_lib.py @@ -39,8 +39,10 @@ import json import tempfile +import securesystemslib from securesystemslib import exceptions as sslib_exceptions from securesystemslib import formats as sslib_formats +from securesystemslib import hash as sslib_hash from securesystemslib import interface as sslib_interface from securesystemslib import keys as sslib_keys from securesystemslib import util as sslib_util @@ -55,8 +57,6 @@ from tuf import sig import tuf.keydb -import securesystemslib -import securesystemslib.hash import six @@ -1187,7 +1187,7 @@ def get_target_hash(target_filepath): """ formats.RELPATH_SCHEMA.check_match(target_filepath) - digest_object = securesystemslib.hash.digest(algorithm=HASH_FUNCTION) + digest_object = sslib_hash.digest(algorithm=HASH_FUNCTION) digest_object.update(target_filepath.encode('utf-8')) return digest_object.hexdigest()