-
Notifications
You must be signed in to change notification settings - Fork 135
Improve post-quantum signature test coverage #4542
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
Open
dralley
wants to merge
6
commits into
pulp:main
Choose a base branch
from
dralley:pqc-coverage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a0510f5
Improve post-quantum signature test coverage
dralley e32df68
Use fetch_url helper for downloads
dralley 8ffc0e7
Generate test RPMs locally instead of fetching fixtures
dralley d94ccc3
Cache fixture signing keys and generalize signer/verifier fixtures
dralley c1c68ac
Enable PQC related tests that require pulpcore support
dralley f32a693
Sign ML-DSA packages via a sq shim for rpm < 4.20
dralley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import pysequoia | ||
| import pytest | ||
| import requests | ||
|
|
||
| from pulp_rpm.tests.functional.conftest import ( | ||
| create_signing_service, | ||
| import_signing_key, | ||
| make_signing_script, | ||
| remove_signing_service, | ||
| ) | ||
| from pulp_rpm.tests.functional.constants import ( | ||
| KEY_V4_RSA4K, | ||
| KEY_V6_MLDSA65_ED25519, | ||
| RPM_UNSIGNED_FIXTURE_URL, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def metadata_signing_service(request, tmp_path, pulpcore_bindings): | ||
| """Create a metadata signing service for the given (key, backend) pair.""" | ||
| key, backend = request.param | ||
| home = tmp_path / "signing" | ||
| home.mkdir(mode=0o700) | ||
|
|
||
| _, fingerprint, _ = import_signing_key(key.private_url, home, backend=backend) | ||
| script_path = make_signing_script(home, fingerprint, tmp_path, backend=backend) | ||
| service_name = create_signing_service(home, fingerprint, script_path, backend=backend) | ||
|
|
||
| service = pulpcore_bindings.SigningServicesApi.list(name=service_name).results[0] | ||
| yield service, key | ||
| remove_signing_service(service_name) | ||
|
|
||
|
|
||
| @pytest.mark.parallel | ||
| @pytest.mark.parametrize( | ||
| "metadata_signing_service", | ||
| [ | ||
| (KEY_V4_RSA4K, "gpg"), | ||
| (KEY_V6_MLDSA65_ED25519, "sq"), | ||
| ], | ||
| indirect=True, | ||
| ) | ||
| def test_publish_signed_repo_metadata( | ||
| metadata_signing_service, | ||
| rpm_repository_factory, | ||
| init_and_sync, | ||
| rpm_publication_factory, | ||
| rpm_distribution_factory, | ||
| distribution_base_url, | ||
| ): | ||
| """Verify that publishing with a metadata signing service produces a signed repomd.xml. | ||
|
|
||
| After syncing and publishing with a metadata signing service attached, the | ||
| distribution should serve `repomd.xml.asc` (detached signature) and | ||
| `repomd.xml.key` (public key) alongside `repomd.xml`, and the | ||
| detached signature should be verifiable with the published public key. | ||
| """ | ||
| service, _key = metadata_signing_service | ||
|
|
||
| repo = rpm_repository_factory(metadata_signing_service=service.pulp_href) | ||
| repo, _ = init_and_sync( | ||
| repository=repo, | ||
| url=RPM_UNSIGNED_FIXTURE_URL, | ||
| policy="on_demand", | ||
| ) | ||
|
|
||
| publication = rpm_publication_factory(repository=repo.pulp_href) | ||
| distribution = rpm_distribution_factory(publication=publication.pulp_href) | ||
| base_url = distribution_base_url(distribution.base_url) | ||
|
|
||
| repomd_resp = requests.get(f"{base_url}/repodata/repomd.xml") | ||
| assert repomd_resp.status_code == 200 | ||
|
|
||
| asc_resp = requests.get(f"{base_url}/repodata/repomd.xml.asc") | ||
| assert asc_resp.status_code == 200 | ||
| assert len(asc_resp.content) > 0, "repomd.xml.asc is empty" | ||
|
|
||
| key_resp = requests.get(f"{base_url}/repodata/repomd.xml.key") | ||
| assert key_resp.status_code == 200 | ||
| assert len(key_resp.content) > 0, "repomd.xml.key is empty" | ||
|
|
||
| # Verify the detached signature using pysequoia | ||
| cert = pysequoia.Cert.from_bytes(key_resp.content) | ||
| sig = pysequoia.Sig.from_bytes(asc_resp.content) | ||
| pysequoia.verify( | ||
| bytes=repomd_resp.content, | ||
| signature=sig, | ||
| store=lambda _key_ids: [cert], | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason do not keep cleaning up the temporary files here? (as
with NamedTemporaryFiledid).It's already uploaded to Pulp's storage and apparently we don't ever need that tmp file again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably happened just because we gave the temp file a name.