Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More flexible file hashing support #991

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tuf/repository_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ def get_metadata_fileinfo(filename, custom=None):
# file information, such as the file's author, version/revision
# numbers, etc.
filesize, filehashes = securesystemslib.util.get_file_details(filename,
securesystemslib.settings.HASH_ALGORITHMS)
tuf.settings.FILE_HASH_ALGORITHMS)

return tuf.formats.make_fileinfo(filesize, filehashes, custom=custom)

Expand Down Expand Up @@ -1531,7 +1531,8 @@ def generate_timestamp_metadata(snapshot_filename, version, expiration_date,

# Retrieve the versioninfo of the Snapshot metadata file.
snapshot_fileinfo = {}
length, hashes = securesystemslib.util.get_file_details(snapshot_filename)
length, hashes = securesystemslib.util.get_file_details(snapshot_filename,
tuf.settings.FILE_HASH_ALGORITHMS)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't see any reason in the spec not to use the same hashing algorithms here as we do in targets?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's my reading as well. The more consistency in algorithm selection between roles the better, IMO.

snapshot_version = get_metadata_versioninfo('snapshot', repository_name)
snapshot_fileinfo[SNAPSHOT_FILENAME] = \
tuf.formats.make_fileinfo(length, hashes, version=snapshot_version['version'])
Expand Down
3 changes: 3 additions & 0 deletions tuf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@
# the securesystemslib external library.
DEFAULT_HASH_ALGORITHM = 'sha256'

# The hashing algorithms used to compute file hashes
FILE_HASH_ALGORITHMS = ['sha256', 'sha512']

# The client's update procedure (contained within a while-loop) can potentially
# hog the CPU. The following setting can be used to force the update sequence
# to suspend execution for a specified amount of time. See
Expand Down