Signing scheme fixes - #757
Merged
Merged
Conversation
_from_crypto() now derives the scheme (RSA or ECDSA P-256) from the actual key bytes instead of assuming RSA, so keys are loaded correctly regardless of type without callers needing to know it in advance (e.g. reading a YubiKey's public key). Adds test_ecdsa_keys.py covering detection, curve/scheme validation, and a sign/verify round trip.
Scheme only matters for key generation; loading/signing now uses the key's own (auto-detected) scheme. Removed the dead parameter across taf/keys.py, taf/keystore.py, the api/* signing/loading functions, and their CLI commands. Also fixes bugs found along the way: add_role/add_target_repo dropped the requested scheme, two functions called register_target_files with misaligned positional arguments, and key_cmd_prompt passed scheme into the wrong parameter.
add_role's scheme argument reached the Role model but was never forwarded into actual key generation, so new keys were always tagged rsa-pkcs1v15-sha256. Threads scheme through load_signer_from_pem so it reaches the real key. Adds skip_prompt to add_target_repo (mirroring add_role) and tests for add_role/add_target_repo scheme handling and update_and_sign_targets (previously untested).
get_sslib_key_from_value and is_valid_metadata_key defaulted to the RSA scheme string, forcing _from_crypto into an awkward tuple check to also treat it as "no opinion" for EC keys. Default to None everywhere instead, so there's exactly one sentinel.
n-dusan
approved these changes
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description (e.g. "Related to ...", etc.)
Signing scheme is now detected from the actual key instead of always being assumed as RSA, as a first step toward supporting elliptic-curve keys.
While tracing how scheme was used, it was found it was already dead in most places outside of key generation, as well as a couple of real bugs: add_role/add_target_repo silently requested non-default scheme when creating new keys, and two functions called register_target_files with misaligned argument. Added tests.
Work on #446
Code review checklist (for code reviewer to complete)