Skip to content
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

Change default keytype to RSA #154

Merged
merged 5 commits into from
Aug 20, 2024
Merged

Conversation

jku
Copy link
Member

@jku jku commented Aug 19, 2024

This is to get deterministic signatures: this is a workaround to get the hash tests fixed now (#128). The change of default might be temporary but all other changes are still useful if we switch back to default ecdsa later (like only generating 8 keys instead of 600 keys):
* Use RSA as the default keytype
* Create a list of RSA signers at repository_simulator.py import time: Use these in all tests to avoid generating keys in every test
* Fix the hash test in test_basic.py: it was incorrect.
* Fix and parametrize the rollback tests (these are the commits from #151)

The last bullet point verifies that this works as I wrote the tests in #151 so they fail with main: now they succeed with this keytype change

jku added 3 commits August 19, 2024 17:26
* Add a test for simple targets rollback
* Fix the test for targets rollback when metafile hashes are used

This now leads to the latter test failing because of theupdateframework#128: This PR can
be used to test the fix for theupdateframework#128. This PR should not be merged before
that.

Signed-off-by: Jussi Kukkonen <[email protected]>
We can parametrize these tests so that they work both with and without
hashes:
* Replace two targets rollback tests with a parametrized test
* Replace on snapshot rollback test with a parametrized test
  (the "with hashes" case was not tested before)

Signed-off-by: Jussi Kukkonen <[email protected]>
This is to get deterministic signatures: this is a workaround to get the
hash tests fixed now.

Fix the hash test in test_basic: it was incorrect.
Signed-off-by: Jussi Kukkonen <[email protected]>
@jku
Copy link
Member Author

jku commented Aug 19, 2024

I'm leaving this a draft until we know if this is acceptable to known external users...

@jku

This comment was marked as outdated.

This is to get deterministic signatures: this is a workaround to get the
hash tests fixed now.
* Use RSA as the default keytype
* Fix the hash test in test_basic: it was incorrect.
* Create a list of signing keys at repository_simulator.py import time:
  Use these keys in all tests to avoid hundreds of keys being generated
  (as RSA key generation is slow)

Signed-off-by: Jussi Kukkonen <[email protected]>
@jku jku linked an issue Aug 19, 2024 that may be closed by this pull request
tuf_conformance/test_basic.py Outdated Show resolved Hide resolved
tuf_conformance/repository_simulator.py Outdated Show resolved Hide resolved
@jku jku marked this pull request as ready for review August 19, 2024 17:48
This wraps popping the next signing key from the pregenerated list
making it:
 * more user friendly if we run out of keys
 * better for the likely near future where we want to generate many more
   keytypes

This commit only supports rsa-pkcs1v15-sha256 but others should be
trivial to add now.

Signed-off-by: Jussi Kukkonen <[email protected]>
@jku
Copy link
Member Author

jku commented Aug 19, 2024

last force push fixes a naming mixup in exception message

@jku jku requested a review from AdamKorcz August 19, 2024 19:59
@jku
Copy link
Member Author

jku commented Aug 20, 2024

I just found out there is a PR to remove support for this keytype in go-tuf: This seems a bit reckless to me but let's make sure that's not the plan ...

@jku jku marked this pull request as draft August 20, 2024 09:47
@jku
Copy link
Member Author

jku commented Aug 20, 2024

No, reading the PR code, it does keep the compatibility. We are good to go

@jku jku marked this pull request as ready for review August 20, 2024 09:57
@jku jku merged commit 2c279ce into theupdateframework:main Aug 20, 2024
3 checks passed
assert client.version(Snapshot.type) == 1
# Verify client refuses targets that does not match hashes
assert client.refresh(init_data) == 1
assert client.version(Snapshot.type) == 3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be v2, since the refresh fails due to the snapshot hash mismatch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mismatch is in targets hash (that is stored in snapshot) -- the docstring could make this clearer:

  • snapshot v3 is a valid snapshot (with meta that contains targets v2).
  • Updating to targets v2 fails because it does not match the hash/length in snapshot meta.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i think this is actually surfacing a bug in my implementation!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants