-
Notifications
You must be signed in to change notification settings - Fork 53
simplify hashing #943
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
Comments
I found this issue difficult to solve and would appreciate feedback on my approach. To address the problem, I created a Python script inside the project directory, print_hash_locations.py, to find all instances where hash-related libraries were imported. I excluded the .tox folder because it contained too many occurrences, and I was unsure of its relevance.
Script Output:
After gathering these results, I went through each script and replaced every occurrence of: With: Once I finished making these changes, I ran tox, but it produced numerous errors. I attempted to resolve some of them, but eventually, I got completely tangled in dependencies and errors. |
This change should be limited to the securesystemslib.hash module as shown in the branch that I linked to. The questions are:
|
I think we kept it, back when we removed all the other legacy code a year ago, because it wasn't obviously broken and used in a few places in tuf and in-toto (#270 (comment)) Removing it likely only means adding a few calls into hashlib in in-toto and tuf, so I'd be inclined to do so. |
I suppose you're not wrong.. so the actual answer to static analysis in python-tuf might include handling hashes there without securesystemslib.hash. |
At least according to sourcegraph, it does not seem to be used beyond python-tuf and in-toto. I'll take a stab at replacing it there. |
I think there's two main uses of
so yeah, seems to not be problematic to just re-implement in python-tuf and in-toto |
securesystemslib.hash is a small wrapper around hashlib, which serves two main purposes: * provide helper function to hash a file * translate custom hash algorithm name "blake2b-256" to "blake2b" with (digest_size=32). In preparation for the removal of securesystemslib.hash, this patch ports above behavior to tuf and uses the builtin hashlib directly where possible. related secure-systems-lab/securesystemslib#943 Signed-off-by: Lukas Puehringer <[email protected]>
securesystemslib.hash is a small wrapper around hashlib, which serves two main purposes: * provide helper function to hash a file * translate custom hash algorithm name "blake2b-256" to "blake2b" with (digest_size=32). In preparation for the removal of securesystemslib.hash, this patch ports above behavior to tuf and uses the builtin hashlib directly where possible. related secure-systems-lab/securesystemslib#943 Signed-off-by: Lukas Puehringer <[email protected]>
securesystemslib.hash is a small wrapper around hashlib, which serves two main purposes: * provide helper function to hash a file * translate custom hash algorithm name "blake2b-256" to "blake2b" with (digest_size=32). In preparation for the removal of securesystemslib.hash, this patch ports above behavior to tuf and uses the builtin hashlib directly where possible. related secure-systems-lab/securesystemslib#943 Signed-off-by: Lukas Puehringer <[email protected]>
securesystemslib.hash is a small wrapper around hashlib, which serves two main purposes: * provide helper function to hash a file * translate custom hash algorithm name "blake2b-256" to "blake2b" with (digest_size=32). In preparation for the removal of securesystemslib.hash, this patch ports above behavior to tuf and uses the builtin hashlib directly where possible. related secure-systems-lab/securesystemslib#943 Signed-off-by: Lukas Puehringer <[email protected]>
I realized my query above didn't include all ways of importing these symbols. I just broadened the search now and got the same result. |
fixes secure-systems-lab#943 * Internal use does not need the additional features (custom blake algorithm name support and file hashing), and was replaced by direct calls to hashlib. * External users were updated to no longer require `securesystemslib.hash` (theupdateframework/python-tuf#2815, in-toto/in-toto#861) Signed-off-by: Lukas Puehringer <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Currently the hash module in securesystemslib supports multiple hash libraries:
hash
is)I think we can keep providing most of the API, but remove the cryptography support (from hashes module) and use only hashlib.
The text was updated successfully, but these errors were encountered: