diff --git a/securesystemslib/interface.py b/securesystemslib/interface.py index b98b2109..84a1d942 100755 --- a/securesystemslib/interface.py +++ b/securesystemslib/interface.py @@ -937,8 +937,11 @@ def import_ecdsa_privatekey_from_file(filepath, password=None, -def import_public_keys_from_file(filepaths, key_types=None): - """Import multiple public keys from files. +def import_publickeys_from_file(filepaths, key_types=None): + """Imports multiple public keys from files. + + NOTE: Use 'import_rsa_publickey_from_file' to specify any other than the + default signing schemes for an RSA key. Arguments: filepaths: A list of paths to public key files. @@ -949,8 +952,8 @@ def import_public_keys_from_file(filepaths, key_types=None): Raises: TypeError: filepaths or key_types (if passed) is not iterable. - securesystemslib.exceptions.FormatError: key_types is passed and does not - have the same length as filepaths or contains an unsupported key type. + FormatError: key_types is passed and does not have the same length as + filepaths or contains an unsupported key type. See import_ed25519_publickey_from_file, import_rsa_publickey_from_file and import_ecdsa_publickey_from_file for other exceptions. @@ -959,7 +962,7 @@ def import_public_keys_from_file(filepaths, key_types=None): """ if key_types is None: - key_types = [securesystemslib.KEY_TYPE_RSA] * len(filepaths) + key_types = [KEY_TYPE_RSA] * len(filepaths) if len(key_types) != len(filepaths): raise securesystemslib.exceptions.FormatError( diff --git a/tests/test_interface.py b/tests/test_interface.py index 87c96edc..f3e80712 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -69,7 +69,7 @@ generate_and_write_ecdsa_keypair, import_ecdsa_publickey_from_file, import_ecdsa_privatekey_from_file, - import_public_keys_from_file) + import_publickeys_from_file) @@ -499,11 +499,11 @@ def test_ecdsa(self): - def test_import_public_keys_from_file(self): + def test_import_publickeys_from_file(self): """Test import multiple public keys with different types. """ # Successfully import key dict with one key per supported key type - key_dict = import_public_keys_from_file([ + key_dict = import_publickeys_from_file([ self.path_rsa + ".pub", self.path_ed25519 + ".pub", self.path_ecdsa + ".pub"], @@ -516,28 +516,28 @@ def test_import_public_keys_from_file(self): ) # Successfully import default rsa key - key_dict = import_public_keys_from_file([self.path_rsa + ".pub"]) + key_dict = import_publickeys_from_file([self.path_rsa + ".pub"]) ANY_PUBKEY_DICT_SCHEMA.check_match(key_dict) RSAKEY_SCHEMA.check_match( list(key_dict.values()).pop()) # Bad default rsa key type for ed25519 with self.assertRaises(Error): - import_public_keys_from_file([self.path_ed25519 + ".pub"]) + import_publickeys_from_file([self.path_ed25519 + ".pub"]) # Bad ed25519 key type for rsa key with self.assertRaises(Error): - import_public_keys_from_file( + import_publickeys_from_file( [self.path_rsa + ".pub"], [KEY_TYPE_ED25519]) # Unsupported key type with self.assertRaises(FormatError): - import_public_keys_from_file( + import_publickeys_from_file( [self.path_ed25519 + ".pub"], ["KEY_TYPE_UNSUPPORTED"]) # Mismatching arguments lists lenghts with self.assertRaises(FormatError): - import_public_keys_from_file( + import_publickeys_from_file( [self.path_rsa + ".pub", self.path_ed25519 + ".pub"], [KEY_TYPE_ED25519])