secure-systems-lab / securesystemslib

Cryptographic and general-purpose routines for Secure Systems Lab projects at NYU
MIT License
48 stars 49 forks source link

Key should expose pre hash algorithm #469

Closed jku closed 1 year ago

jku commented 1 year ago

This is after #456

There could be a optional Key.get_pre_hash_algorithm():

jku commented 1 year ago

I suppose this could be an actual digest() API as well... so you could do something like

hasher = key.hasher() # this is like securesystemslib.hash.digest() except no argument needed 
hasher.update(data)
digest = hasher.digest()

but maybe securesystemslib shouldn't be trying to do all these things?

lukpueh commented 1 year ago

FYI: The HSMSigner API does not need pre-hashing. I only pre-hash in tests as workaround for SoftHSM's limited capabilities:

https://github.com/secure-systems-lab/securesystemslib/blob/c4e3416bbe0fbe06e71449ac15ca96be7bc8a6c4/tests/test_hsm_signer.py#L22-L37

jku commented 1 year ago

oh interesting. If this is only needed by KMS, then we can hold off implementing anything public/generic

jku commented 1 year ago

I'll close this based on above comments