You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
keyids_hash_algorithms missing in private keys? #412
Per Vlad, both public and private keys generated / imported by TUF should include a 'keyid_hash_algorithms' element (which according to tuf.formats.ANYKEY_SCHEMA is optional).
However, this was executed on code current on the develop branch as of this commenting:
I'd recommend that keyid_hash_algorithms be added by the import functions: import_ecdsa_privatekey_from_file, import_ed25519_privatekey_from_file, etc.
Furthermore, I don't see how including the hash algorithms portion in the key object returned by above import_* functions is useful, especially if we only return the key object with a default keyid, and not the other keyids, hashed with other algorithms. Can you elaborate on above "Per Vlad, ... should ..." ?
I prefer not to make keyids_hash_algorithms mandatory at the moment, so we don't cause issues for integrations that don't expect it. Perhaps we can reconsider once we make a major breaking change to the format of key files / objects.
It does not fully make sense to me, that these functions specify a keyid using a default algorithm, e.g. sha256 but pretend to provide flexibility, by adding multiple possible hashing algorithms.
The keyid will always require HASH256, no matter what is specified in the keyid_hash_algorithms field. Doesn't it make more sense to explicitly state which algorithm was used?
Okay, it does make sense now. It is required to associate a key with signatures signed by that key, but potentially having a different key id, due to a different hash algorithm. Thanks for the clarification, Vlad!
I'll update import_ed25519_*, import_rsa_* and import_ecdsa_*
Yup, I added an interface to securesystemslib that does a lot of what repository_lib.py currently does. We should consider using the functions provided by securesystemslib.
Actually the securesystemslib functions load PEM formatted keys, whereas the repository lib functions load json.
I guess, we should provide a load PEM and a load JSON function, for each of (public and private) key, public key, private key, for each of rsa, ed25519 and ecdsa, in securesystemslib.
Keeping the interface in repository_lib makes the most sense. I'd imagine that the format of JSON keys would differ between projects, so adding it to securesystemslib is not ideal.
I don't agree. The JSON/dictionary schemas are integral part of securesystemslib, c.f. securesystemslib.formats. We use the same schemas in in-toto. So I guess it makes sense to move/add the implementation to securesystemslib.keys.
Activity
lukpueh commentedon Jan 27, 2017
Should we just adapt
import_ed25519_privatekey_from_fileto addkeyid_hash_algorithms?Or do we additionally want to make the property mandatory for some or all of
ANYKEY_SCHEMA,RSAKEY_SCHEMA,ECDSAKEY_SCHEMA?vladimir-v-diaz commentedon Jan 27, 2017
I'd recommend that
keyid_hash_algorithmsbe added by the import functions:import_ecdsa_privatekey_from_file,import_ed25519_privatekey_from_file, etc.lukpueh commentedon Jan 27, 2017
Furthermore, I don't see how including the hash algorithms portion in the key object returned by above
import_*functions is useful, especially if we only return the key object with a defaultkeyid, and not the other keyids, hashed with other algorithms. Can you elaborate on above "Per Vlad, ... should ..." ?vladimir-v-diaz commentedon Jan 27, 2017
Here's some background information on
keyid_hash_algorithms: #272Let me know if it clears things up.
lukpueh commentedon Jan 27, 2017
import_ed25519_publickey_from_filealready has wished behavior, see line 1155 but discards the keyids (second return value) as junk.Providing the same behavior for
import_ed25519_privatekey_from_fileis as simple as adding above line to the function.I wonder if we want to (in addition to having the
key_id_hash_algorithmsin the key object):import_ed25519_*functions,import_rsa_*functions,*KEY_SCHEMAs in securesystemslib.formats` to make keyid hash algorithms mandatory?vladimir-v-diaz commentedon Jan 27, 2017
I prefer not to make
keyids_hash_algorithmsmandatory at the moment, so we don't cause issues for integrations that don't expect it. Perhaps we can reconsider once we make a major breaking change to the format of key files / objects.lukpueh commentedon Jan 27, 2017
Hm. I just read your #272 (comment).
It does not fully make sense to me, that these functions specify a
keyidusing a default algorithm, e.g.sha256but pretend to provide flexibility, by adding multiple possible hashing algorithms.Given a key
{ "keyid": HASH256(KEYVAL), "keyid_hash_algorithms": ['sha256', 'sha512'], "keyval" : KEYVAL }The keyid will always require
HASH256, no matter what is specified in thekeyid_hash_algorithmsfield. Doesn't it make more sense to explicitly state which algorithm was used?lukpueh commentedon Jan 27, 2017
Re format: Okay, makes sense.
lukpueh commentedon Jan 27, 2017
Okay, it does make sense now. It is required to associate a key with signatures signed by that key, but potentially having a different key id, due to a different hash algorithm. Thanks for the clarification, Vlad!
I'll update
import_ed25519_*,import_rsa_*andimport_ecdsa_*lukpueh commentedon Jan 27, 2017
Btw. we have partially redundant code in the tuf's repository lib (1) and securesystemslib's key module (2).
(1)
import_rsa_publickey_from_file(filepath)import_rsa_privatekey_from_file(filepath)import_ed25519_publickey_from_file(filepath)import_ed25519_privatekey_from_file(filepath)(2)
import_rsakey_from_pem(pem)import_rsakey_from_public_pem(pem)import_rsakey_from_private_pem(pem)import_ecdsakey_from_pem(pem)import_ecdsakey_from_public_pem(pem)import_ecdsakey_from_private_pem(pem)Should we merge?
vladimir-v-diaz commentedon Jan 27, 2017
Yup, I added an interface to securesystemslib that does a lot of what repository_lib.py currently does. We should consider using the functions provided by securesystemslib.
lukpueh commentedon Jan 27, 2017
Actually the securesystemslib functions load PEM formatted keys, whereas the repository lib functions load json.
I guess, we should provide a load PEM and a load JSON function, for each of (public and private) key, public key, private key, for each of rsa, ed25519 and ecdsa, in securesystemslib.
lukpueh commentedon Jan 27, 2017
Vlad, do you want to keep the interfaces in repository_lib? e.g.:
vladimir-v-diaz commentedon Jan 27, 2017
Keeping the interface in repository_lib makes the most sense. I'd imagine that the format of JSON keys would differ between projects, so adding it to securesystemslib is not ideal.
lukpueh commentedon Jan 27, 2017
I don't agree. The JSON/dictionary schemas are integral part of securesystemslib, c.f.
securesystemslib.formats. We use the same schemas in in-toto. So I guess it makes sense to move/add the implementation tosecuresystemslib.keys.lukpueh commentedon Jan 27, 2017
But yes, we should still keep the interface in repository_lib for backwards compatibility.
lukpueh commentedon Jan 27, 2017
I created a new issue in securesystemslib:
secure-systems-lab/securesystemslib#35
Merge pull request #460 from theupdateframework/lukpueh-fix-#412